Created
May 15, 2019 12:12
-
-
Save katoozi/01628c368b9cd3595a37ec4304167f29 to your computer and use it in GitHub Desktop.
simple gunicorn file
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="django_project" # Name of the application | |
DJANGODIR=/var/www/django_project # Django project directory | |
SOCKFILE=/var/www/django_env/run/gunicorn.sock # we will communicte using this unix socket | |
USER=root # the user to run as | |
GROUP=root # the group to run as | |
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn | |
DJANGO_SETTINGS_MODULE=django_project.settings # which settings file should Django use | |
DJANGO_WSGI_MODULE=django_project.wsgi # WSGI module name | |
echo "Starting $NAME as `whoami`" | |
# Activate the virtual environment | |
cd $django_project | |
source /var/www/django_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 gunicorn ${DJANGO_WSGI_MODULE}:application \ | |
--name $NAME \ | |
--workers $NUM_WORKERS \ | |
--user=$USER --group=$GROUP \ | |
--bind=unix:$SOCKFILE \ | |
--log-level=debug \ | |
--log-file=- |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment