diff options
author | Max Miorim <miorimmax@gmail.com> | 2010-06-14 01:35:07 -0500 |
---|---|---|
committer | Robby Workman <rworkman@slackbuilds.org> | 2010-06-14 03:18:19 -0500 |
commit | 92c7ecbb2f68716e7003e1f4e87d3199775f40ed (patch) | |
tree | 0c56eb31e24035f2f8ca837f3e7b9d93012da4c7 /network/nginx/rc.nginx | |
parent | be790d7cf8685474b215434e8a65a650a05e3e68 (diff) | |
download | slackbuilds-92c7ecbb2f68716e7003e1f4e87d3199775f40ed.tar.gz |
network/nginx: Added (http server and reverse proxy)
Signed-off-by: Robby Workman <rworkman@slackbuilds.org>
Diffstat (limited to 'network/nginx/rc.nginx')
-rw-r--r-- | network/nginx/rc.nginx | 96 |
1 files changed, 96 insertions, 0 deletions
diff --git a/network/nginx/rc.nginx b/network/nginx/rc.nginx new file mode 100644 index 0000000000..f9f377695f --- /dev/null +++ b/network/nginx/rc.nginx @@ -0,0 +1,96 @@ +#!/bin/sh +# +# Nginx daemon control script. +# Written for Slackware Linux by Cherife Li <cherife-#-dotimes.com>. + +BIN=/usr/sbin/nginx +CONF=/etc/nginx/nginx.conf +PID=/var/run/nginx.pid + +nginx_start() { + # Sanity checks. + if [ ! -r $CONF ]; then # no config file, exit: + echo "$CONF does not appear to exist. Abort." + exit 1 + fi + + if [ -s $PID ]; then + echo "Nginx appears to already be running?" + exit 1 + fi + + echo "Starting Nginx server daemon..." + if [ -x $BIN ]; then + $BIN -c $CONF + fi +} + +nginx_test_conf() { + echo "Checking configuration for correct syntax and" + echo "then trying to open files referenced in configuration..." + $BIN -t -c $CONF +} + +nginx_term() { + echo "Shutdown Nginx quickly..." + kill -TERM $(cat $PID) +} + +nginx_stop() { + echo "Shutdown Nginx gracefully..." + kill -QUIT $(cat $PID) +} + +nginx_reload() { + echo "Reloading Nginx configuration..." + kill -HUP $(cat $PID) +} + +nginx_upgrade() { + echo "Upgrading to the new Nginx binary." + echo "Make sure the Nginx binary has been replaced with new one" + echo "or Nginx server modules were added/removed." + kill -USR2 $(cat $PID) + sleep 3 + kill -QUIT $(cat $PID.oldbin) +} + +nginx_rotate() { + echo "Rotating Nginx logs..." + kill -USR1 $(cat $PID) +} + +nginx_restart() { + nginx_stop + sleep 3 + nginx_start +} + +case "$1" in + check) + nginx_test_conf + ;; + start) + nginx_start + ;; + term) + nginx_term + ;; + stop) + nginx_stop + ;; + reload) + nginx_reload + ;; + restart) + nginx_restart + ;; + upgrade) + nginx_upgrade + ;; + rotate) + nginx_rotate + ;; + *) + echo "usage: `basename $0` {check|start|term|stop|reload|restart|upgrade|rotate}" +esac |