WSGID When your WSGI app becomes a *nix daemon
The Project
Wsgid is a generic WSGI handler for mongrel2 web server. Mongrel2 is a non-blocking web server backed by a high performance queue (0mq). Wsgid plays a gateway role between mongrel2 and your WSGI application, offering a full daemon environment with start/stop/reload functionality.
Highlights
Stop/restart an instance without losing requests durring this process
Run you WSGI app in multiple servers, with zero lines of change
Scale horizontally adding new nodes and spawning more wsgid instances
Respawn workers automatically in case of fatal errors
Hot deploy. Just kill a worker and your new code will be loaded
Quick Start
It's very easy to start a new instance of wsgid that will respond to request of your application. You have two main ways to start your application workers. The first (mostly used when testing things out) is to pass all options directly on the command line:
wsgid --app-path=/var/apps/helloapp
--recv=tcp:127.0.0.1:8889 --send=tcp:127.0.0.1:8890
--workers=2
This command will start two instances of wsgid, responding request for the app at /var/apps/helloapp. Each instance (worker) is automatically respawned in case of any fatal error. The pid and returnvalue of the worker are written to the logs.
Another way is to use a config file. The config file is named wsgid.json and lives inside your wsgid app folder. Wsgid can create this config file for you directly from the command line. Just pass config as the first argument to wsgid:
wsgid config --app-path=/var/apps/helloapp
--recv=tcp:127.0.0.1:8889 --send=tcp:127.0.0.1:8890
--workers=2 --keep-alive
This will create wsgid.json with the same options that were passed on command line. Now to start your app you can just do:
wsgid --app-path=/var/apps/helloapp