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

nginx启动脚本

时间:2019-01-18 17:27:37      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:sleep   ons   use   bash   install   skipped   test   init.d   inf   

#!/bin/bash
#
# nginx   Start nginx 
# chkconfig: - 85 15
# description: The nginx is an efficient web server
# processname: nginx
# config: /usr/local/nginx/conf/nginx.conf
# pidfile: /usr/local/nginx/logs/nginx.pid
# 
##################################################
#source function library.
. /etc/init.d/functions

RETVAL=0
# base path
prog="nginx"
binfile="/usr/local/nginx/sbin/nginx"
pidfile="/usr/local/nginx/logs/nginx.pid"
confile="/usr/local/nginx/conf/nginx.conf"
lockfile="/usr/local/nginx/logs/nginx.lock"

if [ ! -x $bindir ];then
    echo -n "$bindir not installed! "
    # Tell the user this has skipped
    exit 5
fi

start(){
    test -e $pidfile && echo  $"Already Starting $prog" && exit 6
    echo -n $"Starting $prog:"
    daemon $binfile -c $confile
    RETVAL=$?
    [ $RETVAL -eq 0 ] && touch $lockfile
    echo 
}

stop(){
    echo -n $"Stopping $prog:"
    killproc -p $pidfile $prog
    RETVAL=$?
    [ $RETVAL -eq 0 ] && rm -f $lockfile $pidfile   
    echo 
}

case "$1" in
    start)
    start
    RETVAL=$?
    ;;
    stop)
    stop
    RETVAL=$?
    ;;
    restart)
    stop
    sleep 2
    start
    RETVAL=$?
    ;;
    reload)
    $binfile -s reload
    ;;      
    status)
    status $binfile
    ;;
    version)
    $binfile -v
        ;;
    configtest)
    $binfile -t
    ;;
    *)
    echo $"Usage: $0 {start|stop|reload|restart|status|version|configtest}"
        exit 2
    ;;
esac
exit $RETVAL

nginx启动脚本

标签:sleep   ons   use   bash   install   skipped   test   init.d   inf   

原文地址:https://www.cnblogs.com/dianel/p/10288355.html

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