-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathrollout.init
executable file
·82 lines (76 loc) · 1.83 KB
/
rollout.init
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
#!/bin/sh
#
# chkconfig: - 91 35 91
# description: Starts and stops the Rollout server
# #
# processname: rolloutd
# pidfile: /var/run/rolloutd.pid
### BEGIN INIT INFO
# Provides: rolloutd
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Run Rollout Server
# Description: Enable Rollout Server
### END INIT INFO
RUN_ON_STARTUP=0
BASEDIR="/usr/local/rollout"
ALLOW="127.0.0.0/24"
LISTEN_ADDRESS="127.0.0.1"
LISTEN_PORT=80
LOGFILE="/var/log/rolloutd.log"
ROLLOUTD="/usr/local/sbin/rolloutd"
PIDFILE="/var/run/rolloutd.pid"
LISTEN_SSL=""
USER=nobody
GROUP=daemon
[ -f /etc/default/rollout ] && . /etc/default/rollout
check_status() {
[ -f ${PIDFILE} ] || return 0
PID=`cat ${PIDFILE}`
[ -z ${PIDFILE} ] && return 0
kill -0 ${PID} 2>/dev/null && return ${PID}
return 0
}
case "$1" in
start)
[ -z ${RUN_ON_STARTUP} -o ${RUN_ON_STARTUP} != 1 ] && exit 0
[ -d ${BASEDIR} ] || mkdir -p "${BASEDIR}"
echo "Starting Rollout"
cd `dirname ${ROLLOUTD}`
${ROLLOUTD} \
--daemon \
--pidfile "${PIDFILE}" \
--base "${BASEDIR}" \
--allow "${ALLOW}" \
--listen "${LISTEN_ADDRESS}:${LISTEN_PORT}" \
${LISTEN_SSL} \
--user "${USER}" \
--group "${GROUP}" \
--logfile "${LOGFILE}" \
>> /var/log/rolloutd.log 2>&1
;;
stop)
check_status && exit 0
PID=`cat ${PIDFILE}`
echo "Stopping Rollout (process $PID)"
kill $PID
rm -f /var/run/rolloutd.pid
;;
restart)
$0 stop
$0 start
exit $?
;;
status)
check_status && echo "Rollout is not running" && exit 1
PID=`cat ${PIDFILE}`
echo "Rollout is running as PID $PID"
exit 0
;;
*)
echo "Usage: $0 {start|stop|restart|status}" >&2
exit 1
;;
esac