Skip to content

Instantly share code, notes, and snippets.

@RamsesMartinez
Forked from MauricioDinki/gunicorn_start
Created April 7, 2017 21:37
Show Gist options
  • Save RamsesMartinez/55e005f664a9f258b283d12b963baed0 to your computer and use it in GitHub Desktop.
Save RamsesMartinez/55e005f664a9f258b283d12b963baed0 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