1
0
forked from ports/contrib

nginx: updated rc script to use start-stop-daemon

This commit is contained in:
Matt Housh 2016-01-10 09:56:16 -06:00
parent a2c18333f7
commit c66e542fb1
3 changed files with 34 additions and 24 deletions

View File

@ -1,3 +1,3 @@
50fdfa08e93ead7a111cba5a5f5735af nginx-1.9.9.tar.gz
93b358681200fe294581cb559d529aee nginx.conf
d640b1d5d4aad2d24f1e0d85bc5c6798 nginx.rc
06712aa2b72397850b0725f2e9d20627 nginx.rc

View File

@ -5,7 +5,7 @@
name=nginx
version=1.9.9
release=1
release=2
source=(http://nginx.org/download/$name-$version.tar.gz \
$name.conf $name.rc)

54
nginx/nginx.rc Normal file → Executable file
View File

@ -1,31 +1,41 @@
#!/bin/sh
#
# /etc/rc.d/nginx: start, stop or restart nginx server
# /etc/rc.d/nginx: start/stop the nginx daemon
#
SSD=/sbin/start-stop-daemon
PROG=/usr/sbin/nginx
PID=/var/run/nginx.pid
case $1 in
start)
PID="`pidof nginx`"
if [ -s /var/run/nginx.pid -a -n "$PID" ]; then
echo "nginx is already running"
exit 1
fi
/usr/sbin/nginx
"start")
$SSD --start --pidfile $PID --exec $PROG
;;
stop)
/usr/sbin/nginx -s quit
"stop")
$SSD --stop --retry 10 --pidfile $PID
;;
"restart")
$0 stop
$0 start
;;
"status")
$SSD --status --pidfile $PID
case $? in
0)
echo "$PROG is running with pid $(cat $PID)"
;;
1)
echo "$PROG is not running but pid file $PID exists"
;;
3)
echo "$PROG is not running"
;;
4)
echo "Unable to determine program status"
;;
esac
;;
restart)
$0 stop; sleep 1; $0 start
;;
status)
PID="`pidof nginx`"
if [ -s /var/run/nginx.pid -a -n "$PID" ]; then
echo "nginx is running. PID(s) = $PID"
else
echo "nginx is not running."
fi
;;
*)
echo "usage: nginx [start|stop|restart]"
echo "Usage: $0 [start|stop|restart|status]"
;;
esac