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,否则无法后台启动;

Logo

开放原子开发者工作坊旨在鼓励更多人参与开源活动,与志同道合的开发者们相互交流开发经验、分享开发心得、获取前沿技术趋势。工作坊有多种形式的开发者活动,如meetup、训练营等,主打技术交流,干货满满,真诚地邀请各位开发者共同参与!

更多推荐