Created
November 21, 2013 15:22
-
-
Save ahankinson/7583454 to your computer and use it in GitHub Desktop.
Gunicorn Startup Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
NAME="imageserve" # Name of the application | |
VIRTUAL_ENV=srv_env | |
DJANGODIR=/data7/srv/webapps/imageserve2 # Django project directory | |
SOCKFILE=/tmp/imageserve.sock # we will communicte using this unix socket | |
USER=www-data # the user to run as | |
GROUP=www-data # the group to run as | |
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | |
DJANGO_SETTINGS_MODULE=imageserve.settings # which settings file should Django use | |
DJANGO_WSGI_MODULE=imageserve.wsgi # WSGI module name | |
echo "Starting $NAME" | |
# Activate the virtual environment | |
cd $DJANGODIR | |
source ${VIRTUAL_ENV}/bin/activate | |
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE | |
export PYTHONPATH=$DJANGODIR:$PYTHONPATH | |
# Create the run directory if it doesn't exist | |
#RUNDIR=$(dirname $SOCKFILE) | |
#test -d $RUNDIR || mkdir -p $RUNDIR | |
# Start your Django Unicorn | |
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon) | |
exec ${VIRTUAL_ENV}/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \ | |
--name $NAME \ | |
--workers $NUM_WORKERS \ | |
--user=$USER --group=$GROUP \ | |
--log-level=debug \ | |
--bind=unix:$SOCKFILE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment