-
Notifications
You must be signed in to change notification settings - Fork 2
/
gunicorn_start-k8s
executable file
·27 lines (24 loc) · 1.22 KB
/
gunicorn_start-k8s
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
#!/usr/bin/env bash
# gunicorn_start
# Author: Michael Stealey <[email protected]>
NAME="hydroshare_app" # Name of the application
DJANGODIR=/hydroshare # Django project directory
NUM_WORKERS=$(python -c "exec(\"import multiprocessing\nprint( multiprocessing.cpu_count() * 2 + 1)\")")
# how many worker processes should Gunicorn spawn
DJANGO_SETTINGS_MODULE=hydroshare.settings # which settings file should Django use
DJANGO_WSGI_MODULE=hydroshare.wsgi # WSGI module name
TIMEOUT_PERIOD=300 # timeout period in seconds
MAX_REQUESTS=1000 # maximum number of requests a worker will process before restarting
### Do not edit below this line ###
echo "Starting $NAME as `whoami`"
# Activate the virtual environment
cd $DJANGODIR
export DJANGO_SETTINGS_MODULE=$DJANGO_SETTINGS_MODULE
export PYTHONPATH=$DJANGODIR:$PYTHONPATH
# Start your Django Unicorn
exec gunicorn ${DJANGO_WSGI_MODULE}:application \
--name $NAME \
--workers $NUM_WORKERS \
--worker-class gevent \
--timeout $TIMEOUT_PERIOD \
--max-requests $MAX_REQUESTS