一个nginx启动关闭重启的shell脚本

#! /bin/sh
### BEGIN INIT INFO
# Provides:           Nginx-php-fpm(fastcgi)
# Required-Start:     $all
# Required-Stop:      $all
# Default-Start:      3 5
# Default-Stop:       0 1 6
# Short-Description: Start and stop nginx-fcgi in external FASTCGI mode
# Description:        Start and stop nginx-fcgi in external FASTCGI mode
# http://www.linxutone.org msn:[email protected]
### END INIT INFO

set -e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DESC=”nginx daemon”
NAME=nginx
DAEMON=/usr/local/nginx/sbin/$NAME
CONFIGFILE=/usr/local/nginx/conf/nginx.conf
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

# Gracefully exit if the package has been removed.
test -x $DAEMON || exit 0

d_start() {
/usr/local/php-fcgi/sbin/php-fpm start > /dev/null 2>&1
$DAEMON -c $CONFIGFILE || echo -n ” already running”
}

d_stop() {
/usr/local/php-fcgi/sbin/php-fpm stop > /dev/null 2>&1
kill -QUIT `cat $PIDFILE` || echo -n ” not running”
}

d_reload() {
/usr/local/php-fcgi/sbin/php-fpm reload > /dev/null 2>&1
kill -HUP `cat $PIDFILE` || echo -n ” can’t reload”
}

case “$1″ in
start)
echo -n “Starting $DESC: $NAME”
d_start
echo “.”
;;
stop)
echo -n “Stopping $DESC: $NAME”
d_stop
echo “.”
;;
reload)
echo -n “Reloading $DESC configuration …”
d_reload
echo “reloaded.”
;;
restart)
echo -n “Restarting $DESC: $NAME”
d_stop
sleep 1
d_start
echo “.”
;;
*)
echo “Usage: $SCRIPTNAME {start|stop|restart|reload}” >&2
exit 3
;;
esac

exit 0

你可能感兴趣的:(负载均衡/集群,Nginx)