This repository was archived by the owner on Mar 8, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 18
Expand file tree
/
Copy pathspawning.debian
More file actions
executable file
·115 lines (105 loc) · 3.19 KB
/
spawning.debian
File metadata and controls
executable file
·115 lines (105 loc) · 3.19 KB
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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
### BEGIN INIT INFO
# Provides: spawning.debian
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts a Spawning daemon
# Description: starts a Spawning daemon
### END INIT INFO
# Usage instructions:
# - Copy this file to your /etc/init.d directory:
# $ sudo cp spawning.debian /etc/init.d/spawning.mysite
# - Change the options below in the "Configuration" section.
# Spawning arguments currently supported are:
# - host (defaults to 127.0.0.1)
# - port (defaults to 8080)
# - access-log (defaults to /dev/null)
# - stderr (defaults to /dev/null)
# - chuid (optional)
# - factory (optional)
# - processes (optional)
# If you have additional arguments to provide (such as
# max-age, watch, workers etc., add them as follows:
# EXTRA_ARGS="max-age=1000 --watch=file" etc.
# - Initialise the script to survive reboots:
# $ sudo update-rc.d spawning.mysite defaults
# - Start your server:
# $ sudo /etc/init.d/spawning.mysite start
NAME="spawning.debian" # change debian to your own site
DESC="Starts a Spawning daemon to run [domain here]"
# This is where your app or settings.py lives
SITE_DIR=/var/www/mysite/
# CONFIGURATION - edit this stuff
# Configure your own spawning here
SPAWNING_BIN=/usr/local/bin/spawning #Path to Spawning executable
PROCESSES=2 # Number of processes to spawn
# Django by default: delete this var to run a WSGI app
FACTORY="spawning.django_factory.config_factory"
PORT="8080"
HOST="127.0.0.1" # listen on loopback by default
CHUID=""
ACCESS_LOG=/dev/null
ERROR_LOG=/dev/null
APP="settings" # Django by default, but put your own app here
# END CONFIGURATION
# Don't edit this
PIDFILE=/var/run/$NAME.pid
# make sure the access_log file exists
if [ ! -e $ACCESS_LOG ]; then
touch $ACCESS_LOG
fi
# make sure the error log file exists
if [ ! -e $ERROR_LOG ]; then
touch $ERROR_LOG
fi
start() {
echo -n "Starting $NAME on $HOST:$PORT...: "
DAEMON_ARGS="--host=$HOST --port=$PORT"
DAEMON_ARGS="$DAEMON_ARGS --stderr=$ERROR_LOG --access-log-file=$ACCESS_LOG"
[ -n "$PROCESSES" ] && DAEMON_ARGS="$DAEMON_ARGS --processes=$PROCESSES"
[ -n "$FACTORY" ] && DAEMON_ARGS="$DAEMON_ARGS --factory=$FACTORY"
[ -n "$CHUID" ] && DAEMON_ARGS="$DAEMON_ARGS --chuid=$CHUID"
[ -n "$EXTRA_ARGS" ] && DAEMON_ARGS="$DAEMON_ARGS $EXTRA_ARGS"
DAEMON_ARGS="$DAEMON_ARGS $APP"
/sbin/start-stop-daemon --start --background --make-pidfile --pidfile=$PIDFILE --chdir $SITE_DIR --exec $SPAWNING_BIN -- $DAEMON_ARGS || return 2
echo $NAME
return 0
}
stop () {
echo -n "Stopping $NAME: "
/sbin/start-stop-daemon --stop --pidfile $PIDFILE
rm -f $PIDFILE
echo $NAME
return
}
status() {
if [ -f "$PIDFILE" ]; then
echo -n "$NAME already running with PIDs: " && cat $PIDFILE && echo
else
echo "$NAME not running"
fi
return
}
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
;;
restart)
stop
sleep 1
start
;;
*)
echo "Usage: $NAME (start|stop|status|restart)"
exit 1
;;
esac
exit $?