-
Notifications
You must be signed in to change notification settings - Fork 1
/
venv_gunicorn.sh
executable file
·31 lines (25 loc) · 1.07 KB
/
venv_gunicorn.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
#!/bin/bash
# ============================================================================
# Utility script for starting gunicorn
# ------------------------------------
# This script is particularly useful as a command target in a Supervisor
# configuration. While Supervisor can handle activating a virtualenv, it's not
# very elegant. Here we can do everything we need to get gunicorn and django
# up and running.
# ============================================================================
SITE_ROOT=$(dirname $0)
SOCKET=$SITE_ROOT/sock/gunicorn
SOCKET_DIRECTORY=$(dirname $SOCKET)
WORKERS=3
WSGI=ww.wsgi
echo "Operating in $SITE_ROOT, socket will be at $SOCKET"
# Making sure the parent directories for the socket exist
test -d $SOCKET_DIRECTORY || mkdir -p $SOCKET_DIRECTORY
echo "Loading virtualenv"
source env/bin/activate
echo "Collecting static files"
python manage.py collectstatic --noinput
echo "Starting gunicorn"
# Using exec because the shell script doesn't need to keep running on its own
# after starting gunicorn.
exec gunicorn --workers $WORKERS --bind unix:$SOCKET $WSGI