Last active
November 1, 2023 07:53
-
-
Save marcusshepp/129c822e2065e20122d8 to your computer and use it in GitHub Desktop.
Django Gunicorn Daemon Script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# django gunicorn script | |
# Generates a Daemon process with Gunicorn. | |
# see processes with ps -aux | |
# tested on: Ubuntu 14.04.3 LTS (GNU/Linux 3.13.0-74-generic x86_64), aws ec2 | |
# Runs on apps built with Django==1.9 | |
# Marcus Shepherd <[email protected]> | |
# 3-12-16 | |
NAME=project # REPLACE WITH BASE DIR NAME | |
SETTINGS=$NAME.settings | |
SOCK=/opt/proc/$NAME-gunicorn.sock | |
PID=/opt/proc/$NAME-gunicorn.pid | |
LOGFILE=/opt/proc/$NAME-gunicorn.log | |
WORKERS=3 | |
echo 'Creating Daemon process for: '$NAME | |
echo 'LOGFILE: '$LOGFILE | |
# this is where .sock .log and .pid get put | |
DIRECT=/opt/proc/ | |
if ! [[ -d $DIRECT ]]; then | |
ls -la /opt/ | |
echo $DIRECT" does not exist.. creating.." | |
sudo mkdir $DIRECT | |
ls -la /opt/ | |
else | |
echo "Yes it does." | |
echo "removing /opt/proc/$NAME*" | |
rm -rf /opt/proc/$NAME* | |
fi | |
gunicorn \ | |
--env DJANGO_SETTINGS_MODULE=$SETTINGS \ | |
$NAME.wsgi:application \ | |
--pid $PID \ | |
--bind unix:$SOCK \ | |
--workers $WORKERS \ | |
--name $NAME \ | |
--daemon \ | |
--log-file=$LOGFILE | |
# run from /opt/project | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment