|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
# This script expects the following ENV variables:
|
|
|
|
# $SOCKS : Path to the dir that holds unix socket file
|
|
|
|
# - Defined as /srv/interlegis/socks in Dockerfile
|
|
|
|
# $HOME : Path to app home work dir.
|
|
|
|
# - Defined as /srv/interlegis/sigi in Dockerfile
|
|
|
|
|
|
|
|
NAME="sigi"
|
|
|
|
SOCKFILE=$SOCKS/sigi.sock
|
|
|
|
NUM_WORKERS=3 # = 2 * CPUs + 1
|
|
|
|
DJANGO_SETTINGS_MODULE=sigi.settings
|
|
|
|
DJANGO_WSGI_MODULE=sigi.wsgi
|
|
|
|
|
|
|
|
echo "Preparing environment and data..."
|
|
|
|
${HOME}/bin/prepare_environment.sh
|
|
|
|
echo "... done!"
|
|
|
|
|
|
|
|
echo "Starting $NAME as `whoami`..."
|
|
|
|
|
|
|
|
cd ${HOME}
|
|
|
|
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
|
|
|
|
export PYTHONPATH=${HOME}:$PYTHONPATH
|
|
|
|
|
|
|
|
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
|
|
|
|
--name $NAME \
|
|
|
|
--workers $NUM_WORKERS \
|
|
|
|
--log-level=debug \
|
|
|
|
--timeout=180 \
|
|
|
|
--graceful-timeout=180 \
|
|
|
|
--bind=unix:$SOCKFILE
|