-
Notifications
You must be signed in to change notification settings - Fork 4
/
Mnginx
87 lines (78 loc) · 1.2 KB
/
Mnginx
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#!/bin/bash
#
#description:
#Mnginx This is the script to manage nginx start or stop or restart
#
#### BEGIN INFO
# Provides: maycap
# Required-Start: null
# Should-Start: null
# version:1.0
# date:2014-6-11
### END INFO
set -e
PROGDIR=/opt/nginx
PROGNAME=nginx
DAEMON=$PROGDIR/sbin/$PROGNAME
CONFIG=$PROGDIR/conf/nginx.conf
PIDFILE=$PROGDIR/logs/$PROGNAME.pid
DESC="Nginx daemon"
test -x $DAEMON || exit 0
check(){
echo "Checking $DESC:$PROGNAME"
$DAEMON -t
}
start(){
echo -n "Starting $DESC:$PROGNAME"
$DAEMON
echo "."
}
stop(){
echo -n "Stopping $DESC:$PROGNAME"
ngpid=` pidstat -r -l | grep 'nginx: master process' | grep -v grep | awk '{print $3}'`
if [[ X"$1" -eq X ]];then
tag=1
else
tag="$1"
fi
case $tag in
1)
kill -QUIT $ngpid
;;
2)
kill -TERM $ngpid
;;
3)
kill -9 $ngpid
;;
*)
echo "Sorry,Please select 1(从容停止),2(快速停止),3(强制停止)"
exit 1
;;
esac
echo "."
}
restart(){
echo -n "Restarting $DESC:$PROGNAME"
$DAEMON -s reload
echo "."
}
case "$1" in
check)
check
;;
start)
start
;;
stop)
stop ${2:-1}
;;
restart|reload)
restart
;;
*)
echo "Usage:$PROGNAME{check|start|stop|restart|reload}" >&2
exit 1
;;
esac
exit 0