106 lines
1.3 KiB
Plaintext
106 lines
1.3 KiB
Plaintext
#
|
|
# /etc/rc.d/nginx
|
|
#
|
|
# Adopted from Fedora Core
|
|
|
|
LOCKFILE=/var/lock/nginx.lock
|
|
PIDFILE=/var/run/nginx.pid
|
|
RETVAL=0
|
|
MAXOPENFILES=16384
|
|
|
|
NGINX=/usr/bin/nginx
|
|
|
|
start()
|
|
{
|
|
if [ -s $PIDFILE ]; then
|
|
echo "Nginx is already running"
|
|
exit 1
|
|
fi
|
|
|
|
# nginx can work with many files at one time
|
|
ulimit -n $MAXOPENFILES
|
|
|
|
$NGINX &>/dev/null
|
|
RETVAL=$?
|
|
}
|
|
|
|
stop() {
|
|
kill -QUIT `cat $PIDFILE` &>/dev/null
|
|
RETVAL=$?
|
|
}
|
|
|
|
restart()
|
|
{
|
|
stop
|
|
sleep 1
|
|
start
|
|
RETVAL=$?
|
|
}
|
|
|
|
reload() {
|
|
kill -HUP `cat $PIDFILE`
|
|
RETVAL=$?
|
|
}
|
|
|
|
testconfig()
|
|
{
|
|
$NGINX -t
|
|
RETVAL=$?
|
|
}
|
|
|
|
# this is not enabled; requires more testing
|
|
upgrade()
|
|
{
|
|
testconfig
|
|
RETVAL=$?
|
|
if [ $RETVAL -eq 0 ]; then
|
|
echo -n $"Sending USR2 signal to upgrade nginx "
|
|
kill -USR2 `cat $PIDFILE`
|
|
RETVAL=$?
|
|
echo
|
|
else
|
|
RETVAL=1
|
|
fi
|
|
}
|
|
|
|
rotate() {
|
|
# it's too verbose when we are called from cron/logrotate and
|
|
# causes useless E-mail warnings in some setups
|
|
#echo -n $"Sending USR1 signal to rotate logs "
|
|
kill -USR1 `cat $PIDFILE`
|
|
#echo
|
|
RETVAL=$?
|
|
}
|
|
|
|
case "$1" in
|
|
start)
|
|
testconfig
|
|
RETVAL=$?
|
|
[ $RETVAL -eq 0 ] && start
|
|
;;
|
|
stop)
|
|
stop
|
|
;;
|
|
reload)
|
|
testconfig
|
|
RETVAL=$?
|
|
[ $RETVAL -eq 0 ] && reload
|
|
;;
|
|
restart)
|
|
restart
|
|
;;
|
|
rotate)
|
|
rotate
|
|
RETVAL=$?
|
|
;;
|
|
testconfig)
|
|
testconfig
|
|
RETVAL=$?
|
|
;;
|
|
*)
|
|
echo "Usage: $0 {start|stop|reload|restart|rotate|testconfig}"
|
|
RETVAL=1
|
|
esac
|
|
|
|
exit $RETVAL
|