Skip to content

Instantly share code, notes, and snippets.

@MauricioDinki
Created February 14, 2016 04:38
Show Gist options
  • Save MauricioDinki/782564693f7a3debd04d to your computer and use it in GitHub Desktop.
Save MauricioDinki/782564693f7a3debd04d to your computer and use it in GitHub Desktop.
gunicorn start to run a django app
#!/bin/bash
# This runs on 9000 port
NAME="appname"
VIRTUALENV="virtualenv folder"
DJANGO_DIR="django root folder"
USER=root
GROUP=sudo
NUM_WORKERS=5
DJANGO_WSGI_MODULE=<wsgi module>
echo "Starting $NAME as `whoami`"
cd $VIRTUALENV
source bin/activate
cd $DJANGO_DIR
# Enviroment variables
export DJANGO_SETTINGS_MODULE=<django settings module>
export PYTHONPATH=$DJANGO_DIR:$PYTHONPATH
exec gunicorn ${DJANGO_WSGI_MODULE} \
--workers $NUM_WORKERS \
--bind=127.0.0.1:9000
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment