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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM