Skip to content

Instantly share code, notes, and snippets.

@DmytroLitvinov
Last active April 25, 2017 07:44
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 DmytroLitvinov/cd81954b1189fa7c62f866662c0a3fd8 to your computer and use it in GitHub Desktop.
Save DmytroLitvinov/cd81954b1189fa7c62f866662c0a3fd8 to your computer and use it in GitHub Desktop.
[gunicorn_start example] Example file of gunicorn_start inside virtualenv #tags: gunicorn
#!/bin/bash
NAME="instagram_app_django" # Name of the application
DJANGODIR=/webapps/dillysocks/instagram-app-django/instagram-app # Django project directory
SOCKFILE=/webapps/dillysocks/instagram-app-django/run/gunicorn.sock # we will communicte using this unix socket
USER=dillysocks # the user to run as
GROUP=webapps # the group to run as
NUM_WORKERS=3 # how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=instagram_service.prod_settings # which settings file should Django use
DJANGO_WSGI_MODULE=instagram_service.wsgi # WSGI module name
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
source ../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 ../bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=debug \
--log-file=-
appdirs==1.4.3
Django==1.10.5
easy-thumbnails==2.3
gunicorn==19.7.1
olefile==0.44
packaging==16.8
Pillow==4.0.0
pkg-resources==0.0.0
psycopg2==2.7.1
pyparsing==2.2.0
requests==2.13.0
six==1.10.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment