-
Notifications
You must be signed in to change notification settings - Fork 2
/
mooc
executable file
·100 lines (78 loc) · 2.58 KB
/
mooc
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
#!/bin/sh
#
# (c) 2016 Ciro Scognamiglio <[email protected]>
### BEGIN INIT INFO
# Provides: mooc
# Required-Start: rethinkdb
# Required-Stop: rethinkdb
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: This starts the mooc service.
# Description: needs rethinkdb
### END INIT INFO
. /lib/lsb/init-functions
DIR=/root/mooc/rest-api/myops2/bin
DAEMON=$DIR/myops2-mooc
DAEMON_NAME=mooc
DAEMONW=$DIR/myops2-web
DAEMONW_NAME=moocweb
DAEMONM=$DIR/myops2-monitor
DAEMONM_NAME=moocmonitor
# Add any command line options for your daemon here
DAEMON_OPTS=""
DAEMONW_OPTS=""
DAEMONM_OPTS=""
# This next line determines what user the script runs as.
# Root generally not recommended but necessary if you are using the Raspberry Pi GPIO from Python.
DAEMON_USER=root
# The process ID of the script when it runs is stored here:
PIDFILE=/var/run/$DAEMON_NAME.pid
PIDFILEW=/var/run/$DAEMONW_NAME.pid
PIDFILEM=/var/run/$DAEMONM_NAME.pid
do_start()
{
log_daemon_msg "Starting $DAEMON_NAME service"
start-stop-daemon --start --background --pidfile $PIDFILE --make-pidfile \
--user $DAEMON_USER --chuid $DAEMON_USER \
--startas /bin/bash -- -c "exec $DAEMON $DAEMON_OPTS >> /var/log/myops2-daemon.log 2>&1"
log_end_msg $?
log_daemon_msg "Starting $DAEMONW_NAME service"
start-stop-daemon --start --background --pidfile $PIDFILEW --make-pidfile \
--user $DAEMON_USER --chuid $DAEMON_USER \
--startas /bin/bash -- -c "exec $DAEMONW $DAEMONW_OPTS >> /var/log/myops2-daemon.log 2>&1"
log_end_msg $?
log_daemon_msg "Starting $DAEMONM_NAME service"
start-stop-daemon --start --background --pidfile $PIDFILEM --make-pidfile \
--user $DAEMON_USER --chuid $DAEMON_USER \
--startas /bin/bash -- -c "exec $DAEMONM $DAEMONM_OPTS >> /var/log/myops2-daemon.log 2>&1"
log_end_msg $?
}
do_stop()
{
log_daemon_msg "Stopping $DAEMON_NAME service"
start-stop-daemon --stop --pidfile $PIDFILE --retry 10
log_end_msg $?
log_daemon_msg "Stopping $DAEMONW_NAME service"
start-stop-daemon --stop --pidfile $PIDFILEW --retry 10
log_end_msg $?
log_daemon_msg "Stopping $DAEMONM_NAME service"
start-stop-daemon --stop --pidfile $PIDFILEM --retry 10
log_end_msg $?
}
case "$1" in
start|stop)
do_${1}
;;
restart|reload|force-reload)
do_stop
do_start
;;
status)
status_of_proc "$DAEMON_NAME" "$DAEMON" && exit 0 || exit $?
;;
*)
echo "Usage: /etc/init.d/$DAEMON_NAME {start|stop|restart|status}"
exit 1
;;
esac
exit 0