zoukankan      html  css  js  c++  java
  • Nginx启动脚本

    #!/bin/bash
    #author Template
    #Time 2018-06-30 22:07
    # chkconfig  2345 40 98
    # description nginx start/stop script
    
    prefix=/usr/local/nginx
    
    Nginx_Bin=${prefix}/sbin/nginx
    Nginx_Pid=${prefix}/logs/nginx.pid
    Nginx_Conf=${prefix}/conf/nginx.conf
    
    . /etc/init.d/functions
    
    function start(){
        
        if [ ! -f ${Nginx_Pid} ];then
        #if [ `netstat -tlunp  | grep nginx | wc -l` -eq 0 ];then
            ${Nginx_Bin}
            RETVAL=$?
            
            if [ ${RETVAL} -eq 0 ];then
                action "Nginx started" /bin/true
            else
                action "Nginx started" /bin/false
            fi
            return ${RETVAL}
        else
            echo "Nginx is running" 
            return 0
        fi
    }
    
    function stop(){
    
        if [ -f ${Nginx_Pid} ];then
    
            ${Nginx_Bin} -s stop
            RETVAL=$?
            if [ ${RETVAL} -eq 0 ];then
                action "Nginx stoped" /bin/true
                return ${RETVAL}
            else
                action  "Nginx stoped" /bin/false
                return ${RETVAL}
            fi
        else
            echo  "Nginx is not running" 
            return 1
    
        fi
    }
    
    function reload(){
        ${Nginx_Bin} -t -q -c ${Nginx_Conf} &> /dev/null
        RETVAL=$?
        if [ $RETVAL -eq 0 ];then
            ${Nginx_Bin} -s reload
            RETVAL=$?
            [ ${RETVAL} -eq 0 ] && action "Nginx reload" /bin/true || action "Nginx reload" /bin/false
        else
            action "Reload" /bin/false
               echo "Please check your configuration"
            return ${RETVAL}
        fi
    
    }
    
    case $1 in
    
        start)
            start
            RETVAL=$?
            ;;
        stop)
            stop
            RETVAL=$?
            ;;
        restart)
            stop
            sleep 1
            start
            RETVAL=$?
            ;;
    
        reload)
            reload
            RETVAL=$?
            ;;
        *)
            echo "Usage: $0 {start|stop|restart|reload}"
            exit 1
    esac
    exit $RETVAL
  • 相关阅读:
    2018.11.5 Nescafe26 T1 小猫爬山
    2018.10.30 NOIp模拟赛T2 数字对
    2018.10.30 NOIp模拟赛 T1 改造二叉树
    2018/7/16 YMOI模拟 NOIP2013D2T3华容道
    数据结构实验
    我的第一个博客
    题解 P5035 【金坷垃】
    题解 P5036 【随机生成树】
    题解 P5037 【抓捕】
    题解 P1328 【生活大爆炸版石头剪刀布】
  • 原文地址:https://www.cnblogs.com/Template/p/9248834.html
Copyright © 2011-2022 走看看