/
gunicorn_start
42 lines (35 loc) · 1.01 KB
/
gunicorn_start
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
#!/bin/bash
# _______ _______ __ __ _______ __ __ _______
# | _ || || |_| || || | | || _ |
# | |_| || _ || || _ || | | || |_| |
# | || | | || || |_| || |_| || |
# | _ | | |_| | | | | ___|| || _ |
# | |_| || || _ || | | || |_| |
# |_______||_______||__| |__||___| |_______||_______|
#
# Copyright (c) 2014 Steve Ivy <steveivy@gmail.com>
#
NAME="boxpub"
FLASKDIR=/opt/boxpub
VENVDIR=/opt/boxpub/env
SOCKFILE=/tmp/boxpub.sock
USER=deploy
GROUP=deploy
NUM_WORKERS=8
HOST=0.0.0.0
PORT=5000
echo "Starting $NAME"
# activate the virtualenv
cd $VENVDIR
source bin/activate
export PYTHONPATH=$FLASKDIR:$PYTHONPATH
# Create the run directory if it doesn't exist
RUNDIR=$(dirname $SOCKFILE)
test -d $RUNDIR || mkdir -p $RUNDIR
# Start gunicorn
exec gunicorn boxpub:boxpub -b $HOST:$PORT \
--name $NAME \
--workers $NUM_WORKERS \
--user=$USER --group=$GROUP \
--log-level=debug \
--bind=unix:$SOCKFILE