forked from tuwiendsg/RuntimeVerification
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathruntime-verification-service
72 lines (64 loc) · 1.64 KB
/
runtime-verification-service
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
### BEGIN INIT INFO
# Provides: runtime-verification-service
# Required-Start:
# Required-Stop:
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start runtime-verification-service daemon
# Description: To start-stop runtime-verification-service
### END INIT INFO
RUN_MODE="daemons"
PYTHON=$(which python)
NAME=runtime-verification-service
DAEMONDIR=$(pwd)
DAEMON=run.py
PIDDIR=/tmp/
PIDFILE=$PIDDIR/runtime-verification-service.pid
. /lib/lsb/init-functions
case "$1" in
start)
log_daemon_msg "Starting runtime-verification-service daemon"
log_progress_msg "mela"
# Make sure we have our PIDDIR, even if it's on a tmpfs
# install -o root -g root -m 755 -d $PIDDIR
if ! start-stop-daemon --start --chdir $DAEMONDIR --quiet --pidfile $PIDFILE --make-pidfile --background --exec $PYTHON $DAEMON; then
log_end_msg 1
exit 1
fi
log_end_msg 0
;;
stop)
log_daemon_msg "Stopping runtime-verification-service daemon"
log_progress_msg "mela"
start-stop-daemon --stop --quiet --pidfile $PIDFILE
# Wait a little and remove stale PID file
sleep 1
if [ -f $PIDFILE ] && ! ps h `cat $PIDFILE` > /dev/null
then
# Stale PID file (Mela was succesfully stopped),
# remove it
rm -f $PIDFILE
fi
log_end_msg 0
;;
restart)
$0 stop
sleep 1
$0 start
;;
status)
pidofproc -p $PIDFILE $JAVA >/dev/null
status=$?
if [ $status -eq 0 ]; then
log_success_msg "runtime-verification-service is running"
else
log_failure_msg "runtime-verification-service is not running"
fi
exit $status
;;
*)
echo "Usage: $0 {start|stop|restart|status}"
exit 1
;;
esac
exit 0