-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnohub-service.sh
72 lines (62 loc) · 1.09 KB
/
nohub-service.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
64
65
66
67
68
69
70
71
72
#!/bin/bash
# system path
#SYSTEM_PATH=$(dirname $(readlink -f "$0"))
SYSTEM_PATH="/root/proxy/glider_0.16.3_linux_amd64"
CMD_STR="./glider -config $SYSTEM_PATH/config/glider.conf"
echo "start service...."
echo $SYSTEM_PATH
pid_file="glider".pid
function dev() {
$CMD_STR
service_start
}
function noHupLog() {
nohup $CMD_STR >"$SYSTEM_PATH"/log.log &
service_start
}
function noHupNoLog() {
nohup $CMD_STR >/dev/null 2>&1 &
service_start
}
function service_start() {
# shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
echo $! > ${pid_file}
else exit 1
fi
}
function service_stop() {
# shellcheck disable=SC2046
kill -9 $(cat ${pid_file})
# shellcheck disable=SC2181
if [[ $? -eq 0 ]]; then
rm -f ${pid_file}
else exit 1
fi
echo "service stop ok"
}
case "$1" in
dev)
dev
;;
log)
noHupLog
;;
start)
noHupNoLog
;;
stop)
service_stop
;;
status)
redis_status
;;
restart|reload)
service_stop
sleep 1
noHupNoLog
;;
*)
echo "Please use start or stop as first argument"
;;
esac