Here is me trying to put life back into this blog.
This post is about running python workers with uWSGI, as unbit puts it - "uWSGI is a fast, self-healing and developer/sysadmin-friendly application container server coded in pure C."
Sahana Eden is developed with Web2py, at Eden we have tasks that sometime require a worker to perform Asynchronously after a job is submitted. One such task is sending out notification events via the Messaging module. We use Web2py's shiny new scheduler library for this, which needs long running Web2py process' to churn out the jobs. We already use uWSGI for our new deployments, so I thought why not see if uWSGI can do the worker management as well.
uWSGI has a nice config option called the mule. Mule - allows you to spawn a Python worker controlled by the uWSGI master. It respawns the worker on death and signalling the master pulls down both the webserver and the worker at the same time. Needed a small script to make Web2py play nice as a uWSGI mule.
Code snippets below:
Script to spawn a Web2py long running scheduler process (You can replace this with your own long running Python process) :
uWSGI config to run the mule:
Post a Comment