forked from jxufeliujj/blog
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.sh
72 lines (60 loc) · 1.14 KB
/
run.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
#!/bin/bash
# =======================================
# Settings
# =======================================
APP=blog
APP_DIR=/root/go/src/github.com/jxufeliujj/blog
LOG_DIR=/root/go/src/github.com/jxufeliujj/blog
PID_FILE=$APP_DIR/pid
# =======================================
# DO NOT CHANGE
# =======================================
# source function library
. /etc/rc.d/init.d/functions
RETVAL=0
start() {
run_cmd="$APP_DIR/blog"
taskset -c 0,15 nohup $run_cmd 2>&1 >> $LOG_DIR/stdout.log &
echo $! > "$PID_FILE"
success && echo "Starting $APP..."
}
stop() {
pid=$(cat $PID_FILE 2>/dev/null)
if checkpid $pid; then
kill "$pid" 2>/dev/null
timeout=30
while checkpid $pid; do
if (( timeout-- == 0 )); then
kill -KILL "$pid" 2>/dev/null
fi
sleep 1
done
success
else
failure
fi
echo "Stopping $APP..."
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload|reload)
restart
;;
status)
status -p $pid_file
RETVAL=$?
;;
*)
echo $"Usage: $0 {start|stop|status|restart|reload|force-reload}"
exit 1
esac
exit $RETVAL