Blog Archive for March 31, 2011

Gunicorn Simple Release Script

March 31, 2011

Here's a simple script, making use of http://drumcoder.co.uk/blog/2011/mar/31/sudo-restart-gunicorn/, which will upload the latest source, run a django syncdb, then a south migrate, and then finally send a HUP signal to gunicorn.

To scripts are required, upload and restart. Here's the upload script:

SRC_DIR=~/path/to/django/app/
DEST_DIR=user@server.co.uk:path/to/django/app
EXCLUDES=~/path/to/django/app/upload_excludes.txt

RSYNC_OPTS="-avz --exclude-from=$EXCLUDES" …

sudo to restart gunicorn

March 31, 2011

My gunicorn process runs as a user that doesn't own the files that make up the Django app it's serving. I wanted a way to be able to restart the gunicorn process (kill -HUP pid) without having to become that user in a shell. In this way it's …