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/sh
#nginx start script
#Date:2017-6-21
#Author:xcn(baishuchao@yeah.net)
#version 2.0
RETVAL=0
path=
"/application/nginx"
#Source functions library
.
/etc/init
.d
/functions
start(){
if
[ ! -f
"$path/logs/nginx.pid"
]
then
[ -x $path
/sbin/nginx
]||
exit
1
$path
/sbin/nginx
RETVAL=$?
if
[ -f $path
/logs/nginx
.pid ];
then
action
"Nginx startup"
/bin/true
else
action
"Nginx startup"
/bin/false
fi
else
echo
"Nginx is running."
fi
return
$RETVAL
}
stop(){
if
[ ! -f
"$path/logs/nginx.pid"
]
then
echo
"nginx is not running.need not to stop it."
else
[ -x $path
/sbin/nginx
]||
exit
1
[ -f
"$path/logs/nginx.pid"
]&&{
kill
`
cat
$path
/logs/nginx
.pid`
RETVAL=$?
}
if
[ ! -f
"$path/logs/nginx.pid"
];
then
action
"Nginx is stopped."
/bin/true
else
action
"Nginx is stopped."
/bin/false
fi
fi
return
$RETVAL
}
case
"$1"
in
start)
start
RETVAL=$?
;;
stop)
stop
RETVAL=$?
;;
restart)
$0 stop
sleep
2
$0 start
RETVAL=$?
;;
reload)
$path
/sbin/nginx
reload
RETVAL=$?
;;
*)
echo
"USAGE:$0 {start|stop|restart|reload}"
esac
exit
$RETVAL
|
本文转自 baishuchao 51CTO博客,原文链接:http://blog.51cto.com/baishuchao/1940464