-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnginx
executable file
·84 lines (75 loc) · 1.74 KB
/
nginx
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
#! /bin/sh
ulimit -n 65535
# Description: Startup script for nginx webserver on Debian. Place in /etc/init.d and
# run 'sudo update-rc.d nginx defaults', or use the appropriate command on your
# distro.
#
#chkconfig: 2345 55 25
#
# Author: Ryan Norbauer <[email protected]>
# Modified: Geoffrey Grosenbach http://topfunky.com
set -e
PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC="nginx daemon"
NAME=nginx
DAEMON=/usr/local/sbin/$NAME
CONFIGFILE=/etc/nginx/nginx.conf
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME
# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0
d_start() {
$DAEMON -c $CONFIGFILE || echo -n " already running"
}
d_stop() {
kill -INT `cat $PIDFILE` || echo -n " not running"
}
waitforexit() {
count=${2:-30}
while [ 0$count -gt 0 ]
do
PIDS=`ps -C$NAME --no-heading e | grep $DAEMON` || break
PIDS=`echo "$PIDS" | awk '{print $1}' | tr '\n' ' '`
echo Remaining processes: $PIDS
d_stop
sleep 2
count=`expr $count - 1`
done
if [ 0$count -eq 0 ];
then
echo Remaining processes: $PIDS
return 1
fi
return 0
}
d_reload() {
kill -HUP `cat $PIDFILE` || echo -n " can't reload"
}
case "$1" in
start|startssl|sslstart|start-SSL)
echo -n "Starting $DESC: $NAME"
d_start
echo "."
;;
stop)
echo -n "Stopping $DESC: $NAME"
d_stop
echo "."
;;
graceful)
echo -n "Reloading $DESC configuration..."
d_reload
echo "reloaded."
;;
restart)
echo -n "Restarting $DESC: $NAME"
waitforexit "nginx" 20
d_start
echo "."
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|restart|reload}" >&2
exit 3
;;
esac
exit 0