-
Notifications
You must be signed in to change notification settings - Fork 0
/
gunicorn_start.example.sh
50 lines (35 loc) · 1.11 KB
/
gunicorn_start.example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#!/usr/local/bin/bash
# Name of the application
NAME="thinkpackage"
# Django project directory
DJANGODIR=/usr/local/www/thinkpackage
# we will communicte using this unix socket
SOCKFILE=/usr/local/www/thinkpackage/run/gunicorn.sock
# the user to run as
USER=www
# the group to run as
GROUP=www
# how many worker processes should Gunicorn spawn
NUM_WORKERS=3
# which settings file should Django use
DJANGO_SETTINGS_MODULE=thinkpackage.settings
# WSGI module name
DJANGO_WSGI_MODULE=thinkpackage.wsgi
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
. ./venv/bin/activate
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start your Django Unicorn
# Programs meant to be run under supervisor should not daemonize themselves (do not use --daemon)
exec ./venv/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--bind=unix:$SOCKFILE \
--log-level=info \
--log-file=-