Skip to content

Instantly share code, notes, and snippets.

@level09
Created March 19, 2012 10:12
Show Gist options
  • Save level09/2106376 to your computer and use it in GitHub Desktop.
Save level09/2106376 to your computer and use it in GitHub Desktop.
Upstart Script for Gunicorn Django + bash script
description "Test Django instance"
start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 5
exec /path/to/test/hello/script.sh
#!/bin/bash
set -e
LOGFILE=/var/log/gunicorn/hello.log
LOGDIR=$(dirname $LOGFILE)
#set how many workers here
NUM_WORKERS=3
# user/group to run as
USER=your_unix_user
GROUP=your_unix_group
cd /path/to/test/hello
#remove if not using virtualenv
source ../bin/activate
#check that log dir exists
test -d $LOGDIR || mkdir -p $LOGDIR
exec ../bin/gunicorn_django -w $NUM_WORKERS \
--user=$USER --group=$GROUP --log-level=debug \
--log-file=$LOGFILE 2>>$LOGFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment