-
Notifications
You must be signed in to change notification settings - Fork 979
/
zkui.sh
executable file
·63 lines (59 loc) · 1.22 KB
/
zkui.sh
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
#!/usr/bin/env bash
PIDFILE=~/zkui.pid
ZKUIBINDIR=$(cd `dirname $0`; pwd)
ZKUICLASSNAME="target/zkui-2.0-SNAPSHOT-jar-with-dependencies.jar"
ZKUI_DAEMON_OUT=$ZKUIBINDIR/zkui.out
start(){
echo "Starting zkui ... $ZKUIBINDIR"
if [ -f "$PIDFILE" ]; then
if kill -0 `cat "$PIDFILE"` > /dev/null 2>&1; then
echo zkui already running as process `cat "$PIDFILE"`.
exit 0
fi
fi
cp config.cfg target
nohup java -jar "$ZKUIBINDIR/$ZKUICLASSNAME" > "$ZKUI_DAEMON_OUT" 2>&1 < /dev/null &
if [ $? -eq 0 ];
then
echo $!>$PIDFILE
if [ $? -eq 0 ];
then
sleep 1
echo STARTED
else
echo FAILED TO WRITE PID
exit 1
fi
else
echo SERVER DID NOT START
exit 1
fi
}
stop(){
echo -n "Stopping zkui ... "
if [ ! -f "$PIDFILE" ]
then
echo "no zkui to stop (could not find file $PIDFILE)"
else
kill -9 $(cat "$PIDFILE")
rm "$PIDFILE"
echo STOPPED
fi
exit 0
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
shift
"$0" stop
sleep 3
"$0" start
;;
*)
echo "Usage: $0 {start|stop|restart}" >&2
esac