dubbo + jenkins持续集成 shell 脚本样例

时间:2021-10-29 09:17:20


   当我们使用dubbo分布式服务架构体系以后,由于服务众多导致部署发布比较费力,于是利用jekins来做持续集成 ,可以很好的解决服务发布部署问题


   这里记录下  shell脚本样例


#!/bin/sh

## java opt
export JAVA_HOME=/usr/local/java/jdk1.8.0_101
export JRE_HOME=$JAVA_HOME/jre

## service name
APP_NAME=test

SERVICE_DIR=/home/instai/instai-eduai/instai-$APP_NAME-service
SERVICE_NAME=wp-$APP_NAME-service
JAR_NAME=$SERVICE_NAME\.jar

cd $SERVICE_DIR

case "$1" in
start)
nohup $JRE_HOME/bin/java -Xms256m -Xmx512m -jar $JAR_NAME >/dev/null 2>1 &
echo "======Start $SERVICE_NAME success====="
;;
stop)
pid=`ps -ef | grep $SERVICE_NAME | grep java | grep -v "grep" | awk '{print $2}'`
if [ "$pid" = "" ]; then
echo "======no $SERVICE_NAME onlive!======"
else
echo "======$SERVICE_NAME process pid is: $pid ======"
echo "====== begin kill -9 $pid ======"
kill -9 $pid
fi
;;
restart)
$0 stop
sleep 2
$0 start
;;
*)
$0 stop
sleep 2
$0 start
;;
esac
exit 0
~