zoukankan      html  css  js  c++  java
  • openresty的service启动脚本

    #!/bin/sh
    #
    # chkconfig: 2345 55 25
    # Description: Nginx init.d script, put in /etc/init.d, chmod +x /etc/init.d/nginx
    #              For Debian, run: update-rc.d -f nginx defaults
    #              For CentOS, run: chkconfig --add nginx
    #
    ### BEGIN INIT INFO
    # Provides:          nginx
    # Required-Start:    $all
    # Required-Stop:     $all
    # Default-Start:     2 3 4 5
    # Default-Stop:      0 1 6
    # Short-Description: nginx init.d script
    # Description:       OpenResty (aka. ngx_openresty) is a full-fledged web application server by bundling the standard Nginx core, lots of 3rd-party Nginx modules, as well as most of their external dependencies.
    ### END INIT INFO
    #
    
    PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
    DESC="Nginx Daemon"
    NAME=nginx
    PREFIX=/usr/local/openresty/nginx
    DAEMON=$PREFIX/sbin/$NAME
    CONF=$PREFIX/conf/$NAME.conf
    PID=$PREFIX/logs/$NAME.pid
    SCRIPT=/etc/init.d/$NAME
    
    if [ ! -x "$DAEMON" ] || [ ! -f "$CONF" ]; then
        echo -e "33[33m $DAEMON has no permission to run. 33[0m"
        echo -e "33[33m Or $CONF doesn't exist. 33[0m"
        sleep 1
        exit 1
    fi
    
    do_start() {
        if [ -f $PID ]; then
            echo -e "33[33m $PID already exists. 33[0m"
            echo -e "33[33m $DESC is already running or crashed. 33[0m"
            echo -e "33[32m $DESC Reopening $CONF ... 33[0m"
            $DAEMON -s reopen -c $CONF
            sleep 1
            echo -e "33[36m $DESC reopened. 33[0m"
        else
            echo -e "33[32m $DESC Starting $CONF ... 33[0m"
            $DAEMON -c $CONF
            sleep 1
            echo -e "33[36m $DESC started. 33[0m"
        fi
    }
    
    do_stop() {
        if [ ! -f $PID ]; then
            echo -e "33[33m $PID doesn't exist. 33[0m"
            echo -e "33[33m $DESC isn't running. 33[0m"
        else
            echo -e "33[32m $DESC Stopping $CONF ... 33[0m"
            $DAEMON -s stop -c $CONF
            sleep 1
            echo -e "33[36m $DESC stopped. 33[0m"
        fi
    }
    
    do_reload() {
        if [ ! -f $PID ]; then
            echo -e "33[33m $PID doesn't exist. 33[0m"
            echo -e "33[33m $DESC isn't running. 33[0m"
            echo -e "33[32m $DESC Starting $CONF ... 33[0m"
            $DAEMON -c $CONF
            sleep 1
            echo -e "33[36m $DESC started. 33[0m"
        else
            echo -e "33[32m $DESC Reloading $CONF ... 33[0m"
            $DAEMON -s reload -c $CONF
            sleep 1
            echo -e "33[36m $DESC reloaded. 33[0m"
        fi
    }
    
    do_quit() {
        if [ ! -f $PID ]; then
            echo -e "33[33m $PID doesn't exist. 33[0m"
            echo -e "33[33m $DESC isn't running. 33[0m"
        else
            echo -e "33[32m $DESC Quitting $CONF ... 33[0m"
            $DAEMON -s quit -c $CONF
            sleep 1
            echo -e "33[36m $DESC quitted. 33[0m"
        fi
    }
    
    do_test() {
        echo -e "33[32m $DESC Testing $CONF ... 33[0m"
        $DAEMON -t -c $CONF
    }
    
    do_info() {
        $DAEMON -V
    }
    
    case "$1" in
     start)
     do_start
     ;;
     stop)
     do_stop
     ;;
     reload)
     do_reload
     ;;
     restart)
     do_stop
     do_start
     ;;
     quit)
     do_quit
     ;;
     test)
     do_test
     ;;
     info)
     do_info
     ;;
     *)
     echo "Usage: $SCRIPT {start|stop|reload|restart|quit|test|info}"
     exit 2
     ;;
    esac
    
    exit 0
  • 相关阅读:
    美化单选按钮
    url的处理
    时间戳处理
    模板渲染引擎手册
    Web前端工具——Live Reload – Chrome扩展
    属性(Properties)和字段在C#中的关系
    MVC3中的Model
    使用System.Web.Mvc.Ajax
    javascript之DOM操作
    Javascript之BOM(window对象)
  • 原文地址:https://www.cnblogs.com/zk-blog/p/13752557.html
Copyright © 2011-2022 走看看