From b79b67ac094361c1a5d038f9185d626ad8e7594a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Felipe=20Mart=C3=ADn?= Date: Thu, 23 May 2013 18:55:19 +0200 Subject: [PATCH] Fixed supervisor-gunicorn configuration --- config/production/app.supervisor.conf | 2 +- config/production/deploy.py | 10 +++++----- config/server/server.sh | 23 ++++++++++++++--------- 3 files changed, 20 insertions(+), 15 deletions(-) diff --git a/config/production/app.supervisor.conf b/config/production/app.supervisor.conf index 093cc52..c257525 100644 --- a/config/production/app.supervisor.conf +++ b/config/production/app.supervisor.conf @@ -1,8 +1,8 @@ [program:gunicorn] command = /home/app/server.sh directory = /home/app +numprocs = 1 user = app -stopsignal = QUIT autostart = true autorestart = true stdout_logfile = /var/log/supervisor/gunicorn.log diff --git a/config/production/deploy.py b/config/production/deploy.py index 409098a..4dce393 100644 --- a/config/production/deploy.py +++ b/config/production/deploy.py @@ -414,11 +414,11 @@ check_status(status) # ================ SERVER ======================= title('Server') -sub('Killing all gunicorn_django instances') -status = call(['killall', 'gunicorn_django'], - stdout=open(os.devnull, 'wb'), - stderr=open(os.devnull, 'wb')) -check_status(status) +#sub('Killing all gunicorn_django instances') +#status = call(['killall', 'gunicorn_django'], +# stdout=open(os.devnull, 'wb'), +# stderr=open(os.devnull, 'wb')) +#check_status(status) sub('Restarting with supervisor') status = call(['sudo', 'supervisorctl', 'restart', 'gunicorn'], diff --git a/config/server/server.sh b/config/server/server.sh index a5042a7..399cf9a 100755 --- a/config/server/server.sh +++ b/config/server/server.sh @@ -1,12 +1,17 @@ #!/bin/bash +set -e -# CONFIG -WORKERS=2 -SETTINGS="herobrine.local_settings" +LOGFILE=/home/app/logs/gunicorn.log +LOGDIR=$(dirname $LOGFILE) +NUM_WORKERS=1 +USER=app +GROUP=app +SETTINGS="herobrine.settings" -# Get environment resources -source .bash_profile -source virtualenv/bin/activate - -# Start -gunicorn_django app --settings=$SETTINGS -w $WORKERS +cd /home/app +source .environment +source ./virtualenv/bin/activate +test -d $LOGDIR || mkdir -p $LOGDIR +exec gunicorn_django app --settings=$SETTINGS -w $NUM_WORKERS \ + --user=$USER --group=$GROUP --log-level=debug \ + --log-file=$LOGFILE 2>>$LOGFILE