Skip to content

Instantly share code, notes, and snippets.

@elky elky/run_gunicorn.sh
Created Jun 12, 2015

Embed
What would you like to do?
Simple example of gunicorn script for Django project
#!/bin/bash
set -e
LOGFILE=/srv/www/website/log/gunicorn.log
LOGDIR=$(dirname $LOGFILE)
NUM_WORKERS=3
SOCKFILE=/srv/www/website/run/gunicorn.sock
RUNDIR=$(dirname $SOCKFILE)
DJANGO_SETTINGS_MODULE=website.settings
DJANGO_WSGI_MODULE=website.wsgi
ADDRESS=127.0.0.1:8080
# user/group to run as
USER=deployer
GROUP=stuff
cd /srv/www/website/
source env/bin/activate
export LC_ALL=en_US.UTF8
test -d $LOGDIR || mkdir -p $LOGDIR
test -d $RUNDIR || mkdir -p $RUNDIR
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--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
You can’t perform that action at this time.