#!/bin/bash
#
#zn for nginx
#
### BEGIN INIT INFO
# Provides: nginx
# Required-Start: $all
# Required-Stop: $all
# Default-Start: 3 5
# Default-Stop: 0 1 6
# Short-Description: starts the nginx web server
# Description: starts nginx using start-stop-daemon
### END INIT INFO
nginxd=/usr/local/nginx/sbin/nginx
nginx_config=/usr/local/nginx/conf/nginx.conf
nginx_pid=/var/log/nginx/nginx.pid
RETVAL=0
NAME=nginx
[ -x $nginxd ] || exit 0
start() {
if [ -e $nginx_pid ];then
echo "nginx already running...."
exit 1
fi
echo -n $"Starting $NAME: "
start-stop-daemon --start --quiet --pidfile \
$nginx_pid --exec $nginxd -- $DAEMON_OPTS || true
echo "ok."
RETVAL=$?
[ $RETVAL = 0 ] && touch /var/lock/subsys/nginx
return $RETVAL
}
stop() {
echo -n $"Stopping $NAME: "
killproc $nginxd
echo "ok."
RETVAL=$?
[ $RETVAL = 0 ] && rm -f /var/lock/subsys/nginx $nginx_pid
}
reload() {
if [ -e $nginx_pid ];then
echo -n $"Reloading $NAME: "
#kill -HUP `cat ${nginx_pid}`
killproc $nginxd -HUP
echo "ok."
else
echo "nginx already stop.."
fi
}
status() {
if [ -e $nginx_pid ];then
echo "nginx already running.."
pgrep $NAME
else
echo "nginx already stop.."
fi
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
reload)
reload
;;
restart)
stop
start
;;
status)
status
;;
*)
echo $"Usage: $NAME {start|stop|restart|reload|status|help}"
exit 1
esac
exit $RETVAL
阅读(1038) | 评论(0) | 转发(0) |