Created
February 7, 2017 09:57
-
-
Save nix1947/bafee6e922de0cfcc9fa7938c9adda27 to your computer and use it in GitHub Desktop.
gunicorn_start.sh
This file contains hidden or 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 | |
# Purpose: Gunicorn starter | |
# Author: [email protected] | |
# Name of an application | |
NAME="Your projectname" | |
# project directory | |
PROJECTDIR=/webapps/example.com | |
# django project virutalenv directory | |
VENVDIR=/webapps/example.com/venv | |
# Project source directory | |
SRCDIR=/webapps/example.com/master/src | |
# Sock file as gunicorn will communicate using unix socket | |
SOCKFILE=$PROJECTDIR/gunicorn.sock | |
# User who runs the app | |
USER=webapps | |
# the group to run as | |
GROUP=webapps | |
# how many worker processes should Gunicorn spawn | |
NUM_WORKERS=3 | |
# which settings file should Django use | |
# If you haven't spit your file it should example.settings only | |
DJANGO_SETTINGS_MODULE=example.settings.production | |
# WSGI module name | |
DJANGO_WSGI_MODULE=example.wsgi | |
# Activate the virtual environment | |
source $VENVDIR/bin/activate | |
# Export the settings module | |
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE | |
# Export the python path from virtualenv dir | |
export PYTHONPATH=$DJANGODIR:$PYTHONPATH | |
# move to src dir !IMPORTANT otherwise it won't work. | |
cd $SRCDIR | |
# Start your Django Unicorn | |
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon) | |
exec $VENVDIR/bin/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