Skip to content

Instantly share code, notes, and snippets.

@k1000
Last active August 29, 2015 14:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save k1000/438ce24c7c2b98ed77fa to your computer and use it in GitHub Desktop.
Save k1000/438ce24c7c2b98ed77fa to your computer and use it in GitHub Desktop.
Server instrumentation with Upstart, Gunicorn, Django
start on runlevel [2345]
stop on runlevel [06]
respawn
respawn limit 10 5
script
NAME=app_name
PORT=8002
NUM_WORKERS=3
TIMEOUT=120
USER=john
GROUP=john
LOGFILE=/var/log/gunicorn/$NAME.log
LOGDIR=$(dirname $LOGFILE)
test -d $LOGDIR || mkdir -p $LOGDIR
cd /home/john/app
exec /home/john/app/env/bin/gunicorn \
--env DJANGO_SETTINGS_MODULE=$NAME.settings \
$NAME.wsgi:application \
-w $NUM_WORKERS -t $TIMEOUT \
--user=$USER --group=$GROUP --log-level=debug \
--name=$NAME -b 127.0.0.1:$PORT
--log-file=$LOGFILE 2>>$LOGFILE
end script
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment