From 5395f9f3e0824d8ae96e38658983e8968670421b Mon Sep 17 00:00:00 2001 From: sxu <602087911@qq.com> Date: Fri, 30 Aug 2024 16:43:48 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=8C=E6=AD=A5=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/deploy.sh | 3 ++- scripts/pipeline.sh | 1 + scripts/start.sh | 27 +++++++++++++++++++++++++++ 3 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 scripts/start.sh diff --git a/scripts/deploy.sh b/scripts/deploy.sh index 9712b33..84083d2 100644 --- a/scripts/deploy.sh +++ b/scripts/deploy.sh @@ -1,5 +1,6 @@ #!/bin/sh -export deploy_path=/opt/builds/${JOB_NAME}/${BUILD_NUMBER} +#export deploy_path=/opt/builds/${JOB_NAME}/${BUILD_NUMBER} +export deploy_path=/opt/builds/${JOB_NAME} echo "--------moveFile start--------------" rm -rf $deploy_path mkdir -p $deploy_path diff --git a/scripts/pipeline.sh b/scripts/pipeline.sh index 2931132..aef41f1 100644 --- a/scripts/pipeline.sh +++ b/scripts/pipeline.sh @@ -5,6 +5,7 @@ pipeline { JAVA_HOME = '/usr/lib/jvm/jdk1.8.0_381' JOBNAME="${JOB_NAME}" JENKINS_NODE_COOKIE = "dontKillMe" + SPRING_PROFILES_ACTIVE = "sgzb_nw_dev" } stages { stage('Check out') { diff --git a/scripts/start.sh b/scripts/start.sh new file mode 100644 index 0000000..ea4c084 --- /dev/null +++ b/scripts/start.sh @@ -0,0 +1,27 @@ +RESOURCE_NAME=sgzb-modules-material-common-3.0.jar + +tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` +if [ ${tpid} ]; then +echo 'Stop Process...' +kill -15 $tpid +fi +sleep 5 +tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` +if [ ${tpid} ]; then +echo 'Kill Process!' +kill -9 $tpid +else +echo 'Stop Success!' +fi + +tpid=`ps -ef|grep $RESOURCE_NAME|grep -v grep|grep -v kill|awk '{print $2}'` +if [ ${tpid} ]; then + echo 'App is running.' +else + echo 'App is NOT running.' +fi + +rm -f tpid +nohup java -jar ./$RESOURCE_NAME --spring.profiles.active=sgzb_nw_dev & +echo $! > tpid +echo Start Success!