#! /bin/bash
#
# Nginx Start up the Nginx server daemon
#
# chkconfig:2345 55 25
# Description:starts and stops the Nginx Web server
#
# # # BEGIN INIT INFO
# Provides:nginx
# Required-start: $all
# Required-stop: $all
# Default-start:2 3 4 5
# default-stop:0 1 6
# Description:starts and stops the Nginx Web server
# # # END INIT INFO
# to install:
# Copy this file To/etc/init.d/nginx
# shell> Chkconfig--add nginx (RedHat)
# shell> update-rc.d-f nginx defaults (Debian)
# to uninstall:
# shell> Chkconfig--del nginx (RedHat)
# shell> Update-rc.d-f nginx Remove
Path=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin
Name=nginx
daemon=/application/nginx/sbin/$NAME
configfile=/application/nginx/conf/$NAME. conf
pidfile=/application/nginx/logs/$NAME. PID
ulimit=10240
Set-e
[-X "$DAEMON"] | | Exit 0
Do_start () {
echo "Starting $NAME ..."
Ulimit-shn $ULIMIT
$DAEMON-C $CONFIGFILE
}
Do_stop () {
echo "Shutting down $NAME ..."
Kill ' Cat $PIDFILE '
}
Do_reload () {
echo "Reloading $NAME ..."
Kill-hup ' Cat $PIDFILE '
}
Case "$" in
Start
[!-F "$PIDFILE"] && Do_start | | echo "Nginx already Running"
Echo-e ". \ndone"
;;
Stop
[-F "$PIDFILE"] && do_stop | | echo "Nginx not Running"
Echo-e ". \ndone"
;;
Restart
[-F "$PIDFILE"] && do_stop | | echo "Nginx not Running"
Do_start
Echo-e ". \ndone"
;;
Reload
[-F "$PIDFILE"] && do_reload | | echo "Nginx not Running"
Echo-e ". \ndone"
;;
*)
N=/etc/init.d/$NAME
echo "Usage: $N {start|stop|restart|reload}" >&2
Exit 1
;;
Esac
Exit 0
Some of the commands are described below:
-H sets the hard resource limit once the setting cannot be increased. ULIMIT–HS 64; Limit hard resources, thread stack size is 64K.
-S sets the soft resource limit, which can be increased after setup, but cannot exceed the hard resource settings. ULIMIT–SN 32; Restrict soft resources, 32 file descriptors.
-N to open the maximum number of file descriptors. Ulimit–n 128; Limit the maximum number of 128 file descriptors that can be used.
Kill-hup change the configuration without stopping and restarting the service.
This article is from the "Victor's Struggle" blog, please be sure to keep this source http://victor2016.blog.51cto.com/6768693/1885092
Nginx Service Auto-start file