nginx + gunicorn

An update

So, an early post covered how I ran nginx+gevent... but since, I've also dallied with gunicorn.

Here's my runit script:

#!/bin/sh

cd /var/www/somewhere.tinbrain.net/app/
. bin/activate
export DJANGO_SETTINGS_MODULE=myapp.settings
exec gunicorn_django -c gunicorn.conf

As you can see, it's very simple, and takes advantage of virtualenv.

Obviously, this requires a gunicorn config script:

user = 'www-data'
group = 'www-data'
proc_name = 'somewhere'
worker_class = 'gevent'
bind = 'unix:/var/www/somewhere.tinbrain.net/server.sock'

def post_fork(server, worker):
    from psyco_gevent import make_psycopg_green
    make_psycopg_green()
    worker.log.info("Made Psycopg Green")

Now... most of that's fairly simple and obvious, except, perhaps, the end.... which is just cribbed from using psycogreen

comments powered by Disqus