首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 其他教程 > 系统运维 >

用start-stop-daemon起步Nginx

2012-11-23 
用start-stop-daemon启动Nginx在前面学习Ubuntu apt-get install nginx 创建的nginx启动脚本中,看到start-

用start-stop-daemon启动Nginx

在前面学习Ubuntu apt-get install nginx 创建的nginx启动脚本中,看到start-stop-daemon的用法。

迅速查了一下手册(用man start-stop-daemon)。这个程序用来启动和关闭系统级别的进程。

下面我用该命令启动我自己编译的nginx程序:

#!/bin/sh### BEGIN INIT INFO# Provides:          nginx# Required-Start:    $local_fs $remote_fs $network $syslog# Required-Stop:     $local_fs $remote_fs $network $syslog# Default-Start:     2 3 4 5# Default-Stop:      0 1 6# Short-Description: starts the nginx web server# Description:       starts nginx using start-stop-daemon### END INIT INFOPATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/binCARRIER_HOME=/home/dist/carrierDAEMON=$CARRIER_HOME/nginx/bin/nginxPID_FILE=$CARRIER_HOME/nginx/nginx.pidCONFIG_FILE=$CARRIER_HOME/nginx/conf/nginx.confDAEMON_OPTS="-c $CONFIG_FILE"NAME=nginxDESC=nginx# Include nginx defaults if availableif [ -f /etc/default/nginx ]; then. /etc/default/nginxfitest -x $DAEMON || exit 0set -e. /lib/lsb/init-functionstest_nginx_config() {if $DAEMON -t $DAEMON_OPTS >/dev/null 2>&1; thenreturn 0else$DAEMON -t $DAEMON_OPTSreturn $?fi}case "$1" instart)echo -n "Starting $DESC: "test_nginx_config# Check if the ULIMIT is set in /etc/default/nginxif [ -n "$ULIMIT" ]; then# Set the ulimitsulimit $ULIMITfistart-stop-daemon --start --quiet --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS || trueecho "$NAME.";;stop)echo -n "Stopping $DESC: "start-stop-daemon --stop --quiet --pidfile $PID_FILE --exec $DAEMON || trueecho "$NAME.";;restart|force-reload)echo -n "Restarting $DESC: "start-stop-daemon --stop --quiet --pidfile $PID_FILE --exec $DAEMON || truesleep 1test_nginx_config# Check if the ULIMIT is set in /etc/default/nginxif [ -n "$ULIMIT" ]; then# Set the ulimitsulimit $ULIMITfistart-stop-daemon --start --quiet --pidfile $PID_FILE --exec $DAEMON -- $DAEMON_OPTS || trueecho "$NAME.";;reload)echo -n "Reloading $DESC configuration: "test_nginx_configstart-stop-daemon --stop --signal HUP --quiet --pidfile $PID_FILE --exec $DAEMON || trueecho "$NAME.";;configtest|testconfig)echo -n "Testing $DESC configuration: "if test_nginx_config; thenecho "$NAME."elseexit $?fi;;status)status_of_proc -p $PID_FILE "$DAEMON" nginx && exit 0 || exit $?;;*)echo "Usage: $NAME {start|stop|restart|reload|force-reload|status|configtest}" >&2exit 1;;esacexit 0



热点排行