jenkins自动部署mysql_jenkins自动部署tomcat脚本

DIR=`dirname $0`

TOMCAT_DIR=/root/NetWorkFlow/apache-tomcat-8.5.16

WEBAPP_DIR=$TOMCAT_DIR/webapps

TMPDIR=/root/NetWorkFlow/tmp

JAVA_HOME=/lib/jvm/jdk1.8.0_131

echo "tomcat dir is ${TOMCAT_DIR}"

if [ $# -ne 1 ] ; then

echo ". deploy.sh  "

exit 1

fi

APP_NAME=$1

APP_FILE=${APP_NAME}.war

TMPFILE_WAR=$TMPDIR/$APP_FILE

export JAVA_HOME

echo "Deploying file [$APP_file],TMPDIR is [$TMPDIR],DIR is [$DIR]"

if [ ! -f "$TMPFILE_WAR" ] ; then

echo "$TMPFILE_WAR is not exists"

exit 1

fi

echo "Remove old backup $TMPDIR/${APP_NAME}_bak"

rm -fr $TMPDIR/${APP_NAME}_bak

cd $TMPDIR

echo "Backup the old app"

mv $WEBAPP_DIR/$APP_NAME $TMPDIR/

mv $APP_NAME ${APP_NAME}_bak

echo "mv war to webapp"

cd $WEBAPP_DIR

mkdir $APP_NAME

cd $APP_NAME

mv $TMPDIR/$APP_FILE $WEBAPP_DIR/$APP_NAME/

unzip $APP_FILE

rm $APP_FILE

cd $TOMCAT_DIR/bin

echo "Stop server system"

#./shutdown.sh

#count=`ps -efc|grep tomcat|wc -l`

#killedNum=0

#echo "count pid num: ${count}"

#if [ $count -gt 1 ]; then

#   PIDS=`ps -efc|grep tomcat|awk -F ‘ ‘ ‘{print $2}’`

#   for PID in $PIDS

#   do

#      let killedNum++

#      echo "kielledNum :${killedNum} pid ${PID}"

#      if [ $count -gt $killedNum ]; then

#         echo "kill current pid ${PID}"

#         kill ${PID}

#      fi

#   done

#fi

set fileformat=unix

#force shutdown tomcat,copy this sh file to tomcat/bin dir

path=${DIR}

#path=/root/Middleware/apache-tomcat-7.0.28-system/bin/

ps -ef|grep $path|grep java|awk ‘{print $2}’

echo "exec ./shutdown.sh"

./shutdown.sh

sleep 3s

#kill -9 pid

ps -ef|grep $path|grep java|awk ‘{print $2}’|xargs kill -9

#success msg

echo "shutdown success"

ps -ef|grep $path|grep java|awk ‘{print $2}’

echo "Start server"

./startup.sh > /dev/null 2>&1

本文由【waitig】发表在等英博客 本文固定链接:jenkins自动部署tomcat脚本 欢迎关注本站官方公众号,每日都有干货分享!

点赞 (0)赏分享 (0)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值