forked from etsy/supergrep
-
Notifications
You must be signed in to change notification settings - Fork 0
/
supergrep.init
executable file
·70 lines (63 loc) · 1.24 KB
/
supergrep.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
#!/bin/bash
# supergrep initd script
#
# chkconfig: - 50 50
# description: Startup script for supergrep
#
# processname: /usr/bin/node
# pidfile: /var/run/stream.pid
# source function library
. /etc/init.d/functions
OPTIONS="/path/to/supergrep/stream.js prodConfig.js"
RETVAL=0
prog="node stream.js prodConfig.js"
pidfile="/var/run/stream.pid"
start() {
echo -n $"Starting $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
daemon /usr/bin/node $OPTIONS &>/dev/null &
RETVAL=$?
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/stream
fi;
echo
return $RETVAL
}
stop() {
echo -n $"Stopping $prog: "
if [ $UID -ne 0 ]; then
RETVAL=1
failure
else
pkill -f "$OPTIONS"
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/stream
fi;
echo
return $RETVAL
}
restart(){
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
status)
status -p $pidfile /usr/bin/node
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart}"
RETVAL=1
esac
exit $RETVAL