每次打包SpringBoot项目后运行ps aux |grep java
和 java -jar
不免有些麻烦,写脚本会方便的多,这里记录一下SpringBoot的运行、调试、关闭、重启脚本的编写
运行
start.sh
#!/bin/sh
echo jar starting...
nohup java -jar /usr/local/apps/app/app.jar >/dev/null &
echo jar start completed!
调试
debug.sh
#!/bin/bash
echo stop application...
source /usr/local/apps/app/bin/stop.sh
echo debuging...
nohup java -Xdebug -Xrunjdwp:transport=dt_socket,server=y,suspend=n,address=5007 -jar /usr/local/apps/app/app.jar >/dev/null &
echo debug completed!
关闭
stop.sh
#!/bin/bash
PID=$(ps -ef | grep app.jar | grep -v grep | awk '{ print $2 }')
if [ -z "$PID" ]
then
echo Application is already stopped
else
echo kill $PID
kill $PID
fi
重启
restart.sh
#!/bin/bash
echo stop application...
source /usr/local/apps/app/bin/stop.sh
echo start application.
source /usr/local/apps/app/bin/start.sh
这样每次打包后,运行一下restart.sh
就行了