Last active
August 29, 2015 14:10
-
-
Save mortn/1f1febef27a61ab8212f to your computer and use it in GitHub Desktop.
Method for starting a Mezzanine/Django site via Upstart script on Ubuntu 14.04
This file contains 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 | |
set -e | |
NUM_WORKERS=3 | |
USER=www-data | |
GROUP=users | |
DIR=$(dirname $0) | |
APPNAME=${DIR##*/} | |
LOGFILE=/var/log/gunicorn/$APPNAME.log | |
LOGDIR=$(dirname $LOGFILE) | |
cd $DIR | |
[ -d $(dirname $LOGFILE) ] || mkdir -p $(dirname $LOGFILE) | |
[ -f ../bin/activate ] || exit 42 | |
source ../bin/activate | |
[ -x ../bin/gunicorn_django ] || exit 43 | |
exec ../bin/gunicorn_django -w $NUM_WORKERS \ | |
--user=$USER --group=$GROUP --log-level=debug \ | |
--log-file=$LOGFILE 2>>$LOGFILE |
This file contains 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
description "Djablo instance" | |
start on runlevel [2345] | |
stop on runlevel [!2345] | |
respawn | |
respawn limit 10 5 | |
env NUM_CORES="$(cat /proc/cpuinfo | grep processor | wc -l)" | |
export NUM_CORES | |
exec /www/django/mezzanine/djablo.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment