cqdevicemgt/scripts/deploy.sh

118 lines
4.7 KiB
Bash

#!/bin/sh
export deploy_path=/opt/builds/${JOB_NAME}/${BUILD_NUMBER}
echo "--------moveFile start--------------"
rm -rf $deploy_path
mkdir -p $deploy_path
cd $deploy_path
rm -rf *.jar
echo "workspace is ${WORKSPACE}"
mv ${WORKSPACE}/sgzb-auth/target/sgzb-auth-1.0.jar $deploy_path
mv ${WORKSPACE}/sgzb-gateway/target/sgzb-gateway-1.0.jar $deploy_path
mv ${WORKSPACE}/sgzb-modules/sgzb-material/target/sgzb-modules-material-1.0.jar $deploy_path
mv ${WORKSPACE}/sgzb-modules/sgzb-system/target/sgzb-modules-system-1.0.jar $deploy_path
chmod 777 *.jar
echo "--------moveFile end--------------"
export sgzb_auth_enable=true
export sgzb_gateway_enable=true
export sgzb_modules_material_enable=true
export sgzb_modules_system_enable=true
export sgzb_auth_jar=sgzb-auth-1.0.jar
export sgzb_gateway_jar=sgzb-gateway-1.0.jar
export sgzb_modules_material_jar=sgzb-modules-material-1.0.jar
export sgzb_modules_system_jar=sgzb-modules-system-1.0.jar
export sgzb_auth_port=39200
export sgzb_gateway_port=39080
export sgzb_modules_material_port=39302
export sgzb_modules_system_port=39201
if($auth_service_enable);then
echo "--------auth开始启动--------------"
echo "--------删除auth开始--------------"
P_ID=`ps -ef | grep -w $sgzb_auth_jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===auth service process not exists or stop success"
else
kill -9 $P_ID
echo "auth service killed success"
fi
nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_auth_jar >/dev/null 2>&1 &
sgzb_auth_pid=`lsof -i:$sgzb_auth_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$sgzb_auth_pid" ]
do
sgzb_auth_pid=`lsof -i:$sgzb_auth_port|grep "LISTEN"|awk '{print $2}'`
done
echo "auth service pid is $sgzb_auth_pid"
echo "--------auth_service 启动成功--------------"
fi
if($sgzb_gateway_enable);then
echo "--------gateway 开始启动--------------"
echo "--------删除gateway开始--------------"
P_ID=`ps -ef | grep -w $sgzb_gateway_jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===gateway process not exists or stop success"
else
kill -9 $P_ID
echo "gateway killed success"
fi
echo "--------删除gateway开始2-------------- $sgzb_gateway_port"
nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_gateway_jar >/dev/null 2>&1 &
echo "--------删除gateway开始3-------------- $sgzb_gateway_port"
sgzb_gateway_pid=`lsof -i:$sgzb_gateway_port|grep "LISTEN"|awk '{print $2}'`
echo "--------删除gateway开始4-------------- $sgzb_gateway_pid"
until [ -n "$sgzb_gateway_pid" ]
do
echo "--------删除gateway开始5-------------- $sgzb_gateway_pid"
sgzb_gateway_pid=`lsof -i:$sgzb_gateway_port|grep "LISTEN"|awk '{print $2}'`
echo "--------删除gateway开始6-------------- $sgzb_gateway_pid"
done
echo "gateway pid is $sgzb_gateway_pid"
echo "--------gateway 启动成功--------------"
fi
if($sgzb_modules_material_enable);then
echo "--------sgzb_modules_material 开始启动--------------"
echo "--------删除sgzb_modules_material开始--------------"
P_ID=`ps -ef | grep -w $sgzb_modules_material_jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===sgzb_modules_material process not exists or stop success"
else
kill -9 $P_ID
echo "sgzb_modules_material killed success"
fi
echo "--------sgzb_modules_material开始部署--------------"
nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_modules_material_jar >/dev/null 2>&1 &
sgzb_modules_material_pid=`lsof -i:$sgzb_modules_material_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$sgzb_modules_material_pid" ]
do
sgzb_modules_material_pid=`lsof -i:$sgzb_modules_material_port|grep "LISTEN"|awk '{print $2}'`
done
echo "sgzb_modules_material pid is $sgzb_modules_material_pid"
echo "--------sgzb_modules_material 启动成功--------------"
fi
if($sgzb_modules_system_enable);then
echo "--------sgzb_modules_system 开始启动--------------"
echo "--------删除sgzb_modules_system开始--------------"
P_ID=`ps -ef | grep -w $sgzb_modules_system_jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===sgzb_modules_system process not exists or stop success"
else
kill -9 $P_ID
echo "sgzb_modules_system killed success"
fi
echo "--------sgzb_modules_system开始部署--------------"
nohup /usr/lib/jvm/jdk1.8.0_381/bin/java -jar $sgzb_modules_system_jar >/dev/null 2>&1 &
sgzb_modules_system_pid=`lsof -i:$sgzb_modules_system_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$sgzb_modules_system_pid" ]
do
sgzb_modules_system_pid=`lsof -i:$sgzb_modules_system_port|grep "LISTEN"|awk '{print $2}'`
done
echo "sgzb_modules_system pid is $sgzb_modules_system_pid"
echo "--------sgzb_modules_system 启动成功--------------"
fi