码迷,mamicode.com
首页 > 其他好文 > 详细

nginx启动脚本

时间:2015-09-17 15:31:36      阅读:170      评论:0      收藏:0      [点我收藏+]

标签:nginx

#!/bin/bash


# chkconfig: - 85 15

# description: The Nginx HTTP Server is an efficient and extensible  \

#              server implementing the current HTTP standards.



# Source function library.

. /etc/rc.d/init.d/functions


nginx=/usr/local/nginx/sbin/nginx

prog=nginx

pidfile=/usr/local/nginx/logs/nginx.pid

lockfile=/var/lock/subsys/nginx

RETVAL=0



start() {

        echo -n $"Starting $prog: "

        daemon --pidfile=${pidfile} $nginx

        RETVAL=$?

        echo

        [ $RETVAL = 0 ] && touch ${lockfile}

        return $RETVAL

}



stop() {

        echo -n $"Stopping $prog: "

        killproc -p ${pidfile}  $nginx

        RETVAL=$?

        echo

        [ $RETVAL = 0 ] && rm -f ${lockfile} ${pidfile}

}


reload() {

    echo -n $"Reloading $prog: "

    if ! $nginx  -t ; then

        echo $"not reloading due to configuration syntax error"

        failure $"not reloading $nginx due to configuration syntax error"

    else

        # Force LSB behaviour from killproc

$nginx -s reload

        RETVAL=$?

        if [ $RETVAL -ne 0 ]; then

            failure $"nginx shutdown"

        fi

    fi

    echo

}





case "$1" in 

   "start" )

start

;;

   "stop" )

stop

;;

   "restart" )

stop

start

;;

   "status" )

status -p ${pidfile} $nginx

RETVAL=$?

;;


    "reload" )

reload

;;

     * )

echo "Usage: `basename $0` {start|stop|restart|status|reload}"

RETVAL=2

;;

esac


exit $RETVAL


nginx启动脚本

标签:nginx

原文地址:http://10706204.blog.51cto.com/10696204/1695574

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!