Skip to content

Instantly share code, notes, and snippets.

@yoxyue
Last active August 29, 2015 14:20
Show Gist options
  • Save yoxyue/46e747e14366868f7ee7 to your computer and use it in GitHub Desktop.
Save yoxyue/46e747e14366868f7ee7 to your computer and use it in GitHub Desktop.
gunicorn_flask_app
#!/bin/bash
NAME="www.abc.com"
FLASKDIR=/home/abc/site
VENVDIR=/home/abc/venv
SOCKFILE=/home/abc/sock
USER=captain
GROUP=captain
NUM_WORKERS=3
echo "Starting $NAME"
# activate the virtualenv
cd $VENVDIR
source bin/activate
export PYTHONPATH=$FLASKDIR:$PYTHONPATH
#Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start you gunicorn
exec gunicorn hello:app -b 127.0.0.1:5000 \
--name $NAME \
--workers $NUM_WORKERS \
--log-level=debug \
--bind=unix:$SOCKFILE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment