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

    SpringBoot启动脚本记录

    #!/bin/sh
    
    ###
    
    #jar包名称
    SERVICE_NAME="cus"
    
    #上一级目录的env文件(指定启动环境dev/test/prod/uat)
    ENVFILE="../env"
    
    #同级目录的pid文件(写入进程id)
    PIDFILE="pid"
    
    checkRunning(){
        if [ -f "$PIDFILE" ]; then
           if  [ -z "`cat $PIDFILE`" ];then
            echo "ERROR: Pidfile '$PIDFILE' exists but contains no pid"
            return 2
           fi
           PID="`cat ${PIDFILE}`"
           RET="`ps -p "${PID}"|grep java`"
           if [ -n "$RET" ];then
             return 0;
           else
             return 1;
           fi
        else
             return 1;
        fi
    }
    
    status(){
        if ( checkRunning );then
             PID="`cat $PIDFILE`"
             echo "'$SERVICE_NAME' is running (pid '$PID')"
             exit 0
        fi
        echo "'$SERVICE_NAME' not running"
        exit 1
    }
    
    
    #start
    start(){
        if ( checkRunning );then
          PID="`cat $PIDFILE`"
          echo "INFO: Process with pid '$PID' is already running"
          exit 0
        fi
        ENVIRONMENT="`cat ${ENVFILE}`"
        java -jar ${SERVICE_NAME}.jar --spring.profiles.active=${ENVIRONMENT} > console.log 2>&1 &
        echo $! > "${PIDFILE}";
    }
    #Í£Ö¹·½·¨
    stop(){
        if ( checkRunning ); then
           PID="`cat ${PIDFILE}`"
           echo "INFO: sending SIGKILL to pid '$PID'"
           kill -KILL $PID
           RET="$?"
           rm -f "${PIDFILE}"
           return $RET
        fi
        echo "INFO: not running, nothing to do"
        return 0
    }
    
    show_help() {
        cat << EOF
    Tasks provided by the sysv init script:
        stop            - terminate instance in a drastic way by sending SIGKILL
        start           - start new instance
        restart         - stop running instance (if there is one), start new instance
        status          - check if '$SERVICE_NAME' process is running
    EOF
      exit 1
    }
    
    # show help
    if [ -z "$1" ];then
    show_help
    fi
    
    case "$1" in
      status)
        status
        ;;
      restart)
        stop
        start
        status
        ;;
      start)
        start
        ;;
      stop)
        stop
        exit $?
        ;;
      *)
    esac
    
  • 相关阅读:
    二维码物流方面的应用与用户体验方面的改进
    css3文本字体
    css文本样式及控制文本的大小写
    css基础知识之列表
    css基础知识之属性选择器
    css基础内容之background
    webstorm常用快捷键
    canvas标签的使用
    HTML格式化
    a标签链接到当前页内指定位置
  • 原文地址:https://www.cnblogs.com/doagain/p/15015078.html
Copyright © 2011-2022 走看看