zoukankan      html  css  js  c++  java
  • SpringBoot2.x应用启动、关闭shell脚本


    本篇主要说明以下内容:

    1.SpringBoot2.x应用启动、关闭的shell脚本


    1 启动脚本

    直接放到同jar包同一个目录下,如下:

    #!/usr/bin/env bash
    
    APPLICATION_NAME='spblearn'
    CURRENT_PATH=`pwd`
    PID=""
    
    if [ -f ${CURRENT_PATH}/logs/${APPLICATION_NAME}.pid ]
    then
        PID=`cat ${CURRENT_PATH}/logs/${APPLICATION_NAME}.pid`
    fi
    
    if [ "${PID}" = "" ]
    then
        echo "start "${APPLICATION_NAME}
    else
        echo "kill -9 "${APPLICATION}
        kill -9 ${PID}
        echo "restart "${APPLICATION_NAME}
    fi
    
    if [ -d `pwd`/logs ]
    then
        rm -rf `pwd`/logs
    fi
    
    mkdir logs
    
    if [ x$1 != x ]
    then
    java -jar -Duser.timezone=GMT+08 ${APPLICATION_NAME}.jar --spring.profiles.active=prod --server.port=$1 > `pwd`/logs/output.log &
    else
    java -jar -Duser.timezone=GMT+08 ${APPLICATION_NAME}.jar --spring.profiles.active=prod > `pwd`/logs/output.log &
    fi
    echo $! > `pwd`/logs/${APPLICATION_NAME}.pid
    
    

    2 关闭脚本

    也同jar包在同一个目录下

    #!/usr/bin/env bash
    
    APPLICATION_NAME='spblearn'
    CURRENT_PATH=`pwd`
    PID=""
    
    if [ -f ${CURRENT_PATH}/logs/${APPLICATION_NAME}.pid ]
    then
        PID=`cat ${CURRENT_PATH}/logs/${APPLICATION_NAME}.pid`
    fi
    
    if [ "${PID}" = "" ]
    then
        echo "no pid file"
    else
        echo "kill "${PID}
        kill -9 ${PID}
    
        rm -rf `pwd`/logs/${APPLICATION_NAME}.pid
    fi
    
    
  • 相关阅读:
    如何修改Myeclipse的JSP模板
    解决----------“win10,不能打字了,已禁用IME”
    Scala学习之For、Function、Lazy(4)
    Scala学习之Tuple、Map、Array
    PHP Cookies
    PHP Cookies
    PHP 文件处理
    PHP include 和 require
    sqlserver2012 评估期已过问题处理
    PHP preg_match正则表达
  • 原文地址:https://www.cnblogs.com/anxminise/p/9907115.html
Copyright © 2011-2022 走看看