This commit is contained in:
yuzchen 2024-01-24 07:47:15 +08:00
parent 09e41af36b
commit f6035c7e81
1 changed files with 26 additions and 8 deletions

View File

@ -1,9 +1,27 @@
#!/bin/sh
echo "--------删除modules demo service开始--------------"
P_ID=`ps -ef | grep -w demo4bonus-0.0.1 | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===modules demo service process not exists or stop success"
else
kill -9 $P_ID
echo "modules demo service killed success"
fi
#echo "--------删除modules demo service开始--------------"
#P_ID=`ps -ef | grep -w demo4bonus-0.0.1 | grep -v "grep" | awk '{print $2}'`
#if [ "$P_ID" == "" ]; then
# echo "===modules demo service process not exists or stop success"
#else
# kill -9 $P_ID
# echo "modules demo service killed success"
#fi
# 找到Springboot项目对应的进程id
pid=`ps -ef | grep demo4bonus-0.0.1-SNAPSHOT.jar | grep -v grep | awk '{print $2}'`
# 如果该项目已经在服务器上启动则kill掉
echo “原应用程序进程id$pid
if [ -n "$pid" ]
then
kill -9 $pid
fi
echo "授权"
# 让root用户对jar包持有读执行的权限
chmod 777 /opt/webapps/demo4bonus-0.0.1-SNAPSHOT.jar
echo "执行"
# jenkins默认会将新打包好的jar包放到/root/.jenkins/workspace/目录下,进入到该目录
cd /opt/webapps/
# 目标服务器后台方式启动jar包
nohup java -jar demo4bonus-0.0.1-SNAPSHOT.jar >/dev/null 2>&1 &
#nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $exam_system_service_jar >/dev/null 2>&1 &
echo "启动成功"