Linux下SpringBoot项目启停脚本
Posted 默辨
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Linux下SpringBoot项目启停脚本相关的知识,希望对你有一定的参考价值。
最近工作用到该脚本,故作此记录。
启动命令:./app.sh start
停止命令:./app.sh stop
强制停止命令:./app.sh stop -f
可能涉及其他命令:
给app.sh文件赋权限:chmod 777 app.sh
修改shell脚本编码格式:vi进入文件,esc :
set ff=unix
projectName:需要启动的jar包的名字
#!/bin/sh
appName=projectName
if [ -z $appName ]
then
echo "Please check that this script and your jar-package is in the same directory!"
exit 1
fi
killForceFlag=$2
function start()
count=`ps -ef |grep java|grep $appName|wc -l`
if [ $count != 0 ];then
echo "Maybe $appName is running, please check it..."
else
echo "The $appName is starting..."
nohup java -jar -Xms3072m -Xmx4096m -Xmn1536m -XX:+UseAdaptiveSizePolicy -XX:+UseParallelOldGC -XX:MaxGCPauseMillis=100 -XX:+PrintGCDetails -XX:+PrintTenuringDistribution -Xloggc:gclog.log -DWORKING_PATH=/home/working8077 $appName >/home/working8077/springboot.log 2>&1 &
echo "Java -jar over"
fi
function stop()
appId=`ps -ef |grep java|grep $appName|awk 'print $2'`
if [ -z $appId ]
then
echo "Maybe $appName not running, please check it..."
else
echo -n "The $appName is stopping..."
if [ "$killForceFlag" == "-f" ]
then
echo "by force"
kill -9 $appId
else
echo
kill $appId
fi
fi
function usage()
echo "Usage: $0 start|stop|stop -f"
echo "Example: $0 start"
exit 1
case $1 in
start)
start;;
stop)
stop;;
*)
usage;;
esac
以上是关于Linux下SpringBoot项目启停脚本的主要内容,如果未能解决你的问题,请参考以下文章