Pre Steps:
停止原来运行的jar包
pid=`ps -ef | grep gateway-1.0-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
if [ -n "$pid" ]
then
kill -9 $pid
fi
Post Steps:
移动jar包到指定目录,并后台启动
OLD_BUILD_ID=$BUILD_ID
echo $OLD_BUILD_ID
export BUILD_ID=1690
file="/usr/local/jar/"
if [ ! -d $file ];then
mkdir $file
else
fi
jarname="usr/local/jar/gateway-1.0-SNAPSHOT.jar"
if [ ! -f $jarname ];then
else
rm -f $jarname
fi
mv -f /root/.m2/repository/org/example/gateway/1.0-SNAPSHOT/gateway-1.0-SNAPSHOT.jar /usr/local/jar/gateway-1.0-SNAPSHOT.jar
nohup java -jar /usr/local/jar/gateway-1.0-SNAPSHOT.jar > /usr/local/jar/Log.log &
echo "启动服务完成"
BUILD_ID=$OLD_BUILD_ID
echo $BUILD_ID
注意:
export BUILD_ID=1690
必须要加export,否则无法后台启动;