Nginx Service Auto-start file

Source: Internet
Author: User
Tags nginx server

#! /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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.