From 43e06493b72014d86b00d2b54f8f4c1ee520be33 Mon Sep 17 00:00:00 2001 From: liangliangyy Date: Sat, 19 Nov 2016 00:16:25 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=85=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- bin/django_start | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 bin/django_start diff --git a/bin/django_start b/bin/django_start new file mode 100755 index 0000000..c3e8809 --- /dev/null +++ b/bin/django_start @@ -0,0 +1,32 @@ +#!/bin/bash + +NAME="djangoblog" # Name of the application +DJANGODIR=//var/www/DjangoBlog # Django project directory +SOCKFILE=/var/www/DjangoBlog/run/gunicorn.sock # we will communicte using this unix socket +USER=root # the user to run as +GROUP=root # the group to run as +NUM_WORKERS=3 # how many worker processes should Gunicorn spawn +DJANGO_SETTINGS_MODULE=DjangoBlog.settings # which settings file should Django use +DJANGO_WSGI_MODULE=DjangoBlog.wsgi # WSGI module name + +echo "Starting $NAME as `whoami`" + +# Activate the virtual environment +cd $DJANGODIR +source /root/dev/python3/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 /root/dev/python3/bin/gunicorn ${DJANGO_WSGI_MODULE}:application \ +--name $NAME \ +--workers $NUM_WORKERS \ +--user=$USER --group=$GROUP \ +--bind=unix:$SOCKFILE \ +--log-level=debug \ +--log-file=-