3
# Provides: FastCGI servers for Django
4
# Required-Start: networking
5
# Required-Stop: networking
6
# Default-Start: 2 3 4 5
7
# Default-Stop: S 0 1 6
8
# Short-Description: Start FastCGI servers with Django.
9
# Description: Django, in order to operate with FastCGI, must be started
10
# in a very specific way with manage.py. This must be done
11
# for each Django web server that has to run.
14
# Author: Guillermo Fernandez Castellanos
15
# <guillermo.fernandez.castellanos AT gmail.com>.
17
# Changed: Jannis Leidel
18
# <jannis AT leidel.info>
22
# Version: @(#)fastcgi 0.3 05-Aug-2008 joost AT cassee.net
27
#### CONFIGURATION (override in /etc/default/django)
29
# django project names/directories
32
# path to the directory with your django projects
33
SITES_PATH=/var/lib/django
35
# path to the directory for socket and pid files
36
RUNFILES_PATH=/var/run/django
38
# please make sure this is NOT root
39
# local user prefered, www-data accepted
42
# maximum requests before fast-cgi process respawns
43
# (a.k.a. get killed and let live)
46
#### END CONFIGURATION
48
# Include defaults if available
49
if [ -f /etc/default/django ] ; then
53
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
54
DESC="Django FastCGI servers"
56
SCRIPTNAME=/etc/init.d/$NAME
57
mkdir -p $RUNFILES_PATH
58
chown -R $RUN_AS:$RUN_AS $RUNFILES_PATH
61
# Function that starts the daemon/service.
65
# Starting all Django FastCGI processes
67
for SITE in $DJANGO_SITES
70
if [ -f $RUNFILES_PATH/$SITE.pid ]; then
71
echo -n " already running"
73
start-stop-daemon --start --quiet \
74
--pidfile $RUNFILES_PATH/$SITE.pid \
75
--chuid $RUN_AS --exec /usr/bin/env -- python \
76
$SITES_PATH/$SITE/manage.py runfcgi \
77
protocol=fcgi method=threaded maxrequests=$MAXREQUESTS \
78
socket=$RUNFILES_PATH/$SITE.socket \
79
pidfile=$RUNFILES_PATH/$SITE.pid
80
chmod 400 $RUNFILES_PATH/$SITE.pid
87
# Function that stops the daemon/service.
90
# Killing all Django FastCGI processes running
91
for SITE in $DJANGO_SITES
94
start-stop-daemon --stop --quiet --pidfile $RUNFILES_PATH/$SITE.pid \
95
|| echo -n " not running"
96
if [ -f $RUNFILES_PATH/$SITE.pid ]; then
97
rm -f $RUNFILES_PATH/$SITE.pid
106
echo -n "Starting $DESC: $NAME"
112
echo -n "Stopping $DESC: $NAME"
117
restart|force-reload)
118
echo -n "Restarting $DESC: $NAME"
126
echo "Usage: $NAME {start|stop|restart|force-reload}" >&2