-
Notifications
You must be signed in to change notification settings - Fork 2
/
jiradataendpoint.tmp
50 lines (42 loc) · 1.11 KB
/
jiradataendpoint.tmp
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
. /etc/rc.d/init.d/functions
SERVER="SERVERPLACEHOLDER"
LOCK_FILE="/var/lock/subsys/jiradataendpoint"
do_start()
{
if [ ! -f "$LOCK_FILE" ] ; then
echo -n $"Starting JiraData Endpoint: "
runuser -l "root" -c "cd $SERVER && node main.js &" && echo_success || echo_failure
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $LOCK_FILE
else
echo "$SERVER is locked."
RETVAL=1
fi
}
do_stop()
{
echo -n $"Stopping JiraData Endpoint: "
pid=`ps -aefw | grep "node main.js" | grep -v " grep " | awk '{print $2}'`
kill -9 $pid > /dev/null 2>&1 && echo_success || echo_failure
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $LOCK_FILE
}
case "$1" in
start)
do_start
;;
stop)
do_stop
;;
restart)
do_stop
do_start
;;
*)
echo "Usage: $0 {start|stop|restart}"
RETVAL=1
esac
exit $RETVAL