-
Notifications
You must be signed in to change notification settings - Fork 38
/
initscript
executable file
·50 lines (46 loc) · 1.46 KB
/
initscript
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
#! /bin/sh
### BEGIN INIT INFO
# Provides: rw_scanner rw_backend rw_api
# Required-Start: $remote_fs $network $time $syslog postgresql memcache nginx
# Required-Stop: $remote_fs $network $time $syslog postgresql memcache nginx
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Rainwave services
### END INIT INFO
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
set -e
case "$1" in
start)
echo -n "Starting Rainwave Scanner: "
start-stop-daemon --start --background -d /opt/rainwave --exec pipenv run rw_scanner.py
echo "OK"
echo -n "Starting Rainwave API: "
start-stop-daemon --make-pidfile --pidfile /var/run/rainwave/_api_core.pid --start --background -d /opt/rainwave --exec pipenv run rw_api.py
echo "OK"
echo -n "Starting Rainwave Backend: "
start-stop-daemon --make-pidfile --pidfile /var/run/rainwave/_backend_core.pid --start --background -d /opt/rainwave --exec pipenv run rw_backend.py
echo "OK"
;;
stop)
start-stop-daemon --stop --oknodo --pidfile /var/run/rainwave/_api_core.pid
start-stop-daemon --stop --oknodo --pidfile /var/run/rainwave/_backend_core.pid
sleep 1
for pidfile in `ls --ignore=_* /var/run/rainwave`
do
echo -n "Stopping $pidfile: "
start-stop-daemon --oknodo --stop --pidfile /var/run/rainwave/$pidfile
if [ $? -eq 0 ]
then
rm /var/run/rainwave/$pidfile
echo "OK"
else
echo "**bad**"
fi
done
;;
*)
echo "Usage: $0 {start|stop}" >&2
exit 1
;;
esac
exit 0