SprintBoot项目服务启停脚本
Posted malukang
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了SprintBoot项目服务启停脚本相关的知识,希望对你有一定的参考价值。
SprintBoot项目服务启停脚本
vim springboot.sh
#!/bin/bash export BUILD_ID=DONTKILLME APP_NAME=$2 #APP_NAME=admin-1.0-SNAPSHOT function stop(){ PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v $0|awk ‘{print $2}‘` if [[ -n "$PID" ]];then echo ‘Stop Process...‘ kill -15 $PID fi PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v $0|awk ‘{print $2}‘` if [[ -n "$PID" ]];then echo "PID: $PID" echo ‘Kill Process!.....‘ kill -9 $PID else echo ‘No pid, No process,Stop Success!....‘ fi } function start(){ # java -version if [ $? = 0 ];then ## nohup java -jar ${APP_NAME}.jar --spring.config.location=conf/application.yml > /dev/null 2>&1 & JAVA_OPTS=" -Djava.awt.headless=true -Djava.net.preferIPv4Stack=true " JAVA_MEM_OPTS=" -server -Xmx512m -Xms512m -Xmn256m -XX:PermSize=128m -Xss256k -XX:+DisableExplicitGC -XX:+UseConcMarkSweepGC -XX:+CMSParallelRemarkEnabled -XX:+UseCMSCompactAtFullCollection -XX:LargePageSizeInBytes=128m -XX:+UseFastAccessorMethods -XX:+UseCMSInitiatingOccupancyOnly -XX:CMSInitiatingOccupancyFraction=70 " nohup java $JAVA_OPTS $JAVA_MEM_OPTS -jar ${APP_NAME}.jar --spring.profiles.active=dev > /dev/null 2>&1 & echo $! $? echo Start Success! else echo "java is not installed" fi } function status(){ PID=`ps -ef|grep $APP_NAME|grep -v grep|grep -v $0|awk ‘{print $2}‘` if [[ -n "$PID" ]]; then echo "PID:$PID" echo "$APP_NAME is running." else echo "$APP_NAME is downing." fi } ## 入口 case $1 in start) start ;; stop) stop ;; status) status ;; *) echo "./springboot.sh start/stop/status jar-package-name" ;; esac exit 0
脚本使用:
sh springboot.sh ($1)stop ($2)admin-1.0-SNAPSHOT
$1 为start stop status
$2 为启动的jar包的名称
以上是关于SprintBoot项目服务启停脚本的主要内容,如果未能解决你的问题,请参考以下文章