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
  • 相关阅读:
    HTML5+php图片自由裁剪上传功能
    一个日期时间显示框的美化风格示例
    PHP+jquery 瀑布流+LightBox图片盒子特效
    类型
    异常语句
    穷举
    练习
    累加求和
    猜拳游戏(三局两胜)
    正则表达式
  • 原文地址:https://www.cnblogs.com/Template/p/9248834.html
Copyright © 2011-2022 走看看