JAVA部分
echo "取得最新程序完毕"cd /var/lib/jenkins/workspace/XXXXXXX
mvn clean
echo "清理完毕"
mvn package -Dmaven.test.skip=true
echo "打包完毕"
sh /home/jar/jar.sh stop
echo "停止服务"
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/springCloudEurekaService/target/springCloudEurekaService-1.0-SNAPSHOT.jar /home/jar/springCloudEurekaService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/springCloudAdminService/target/springCloudAdminService-1.0-SNAPSHOT.jar /home/jar/springCloudAdminService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/springCloudConfigService/target/springCloudConfigService-1.0-SNAPSHOT.jar /home/jar/springCloudConfigService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/productService/target/productService-1.0-SNAPSHOT.jar /home/jar/productService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/userService/target/userService-1.0-SNAPSHOT.jar /home/jar/userService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/systemService/target/systemService-1.0-SNAPSHOT.jar /home/jar/systemService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/orderService/target/orderService-1.0-SNAPSHOT.jar /home/jar/orderService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/foreignService/target/foreignService-1.0-SNAPSHOT.jar /home/jar/foreignService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/wechatService/target/wechatService-1.0-SNAPSHOT.jar /home/jar/wechatService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/gatewayService/target/gatewayService-1.0-SNAPSHOT.jar /home/jar/gatewayService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/contentService/target/contentService-1.0-SNAPSHOT.jar /home/jar/contentService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/businessEngine/target/businessEngine-1.0-SNAPSHOT.jar /home/jar/businessEngine-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/taskService/target/taskService-1.0-SNAPSHOT.jar /home/jar/taskService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/collocationService/target/collocationService-1.0-SNAPSHOT.jar /home/jar/collocationService-1.0-SNAPSHOT.jar
/bin/cp -f /var/lib/jenkins/workspace/XXXXXXX/retailStoreService/target/retailStoreService-1.0-SNAPSHOT.jar /home/jar/retailStoreService-1.0-SNAPSHOT.jar
echo "拷贝数据完毕"
sleep 2s
cd /home/jar/
echo "启动服务开始"
sh jar.sh start
echo "服务启动完毕" jar.sh 如下 #!/bin/sh
export EUREKA=springCloudEurekaService-1.0-SNAPSHOT.jar
export CONFIG=springCloudConfigService-1.0-SNAPSHOT.jar
export GATEWAY=gatewayService-1.0-SNAPSHOT.jar export EUREKA_port=9999
export CONFIG_port=9000
export GATEWAY_port=9001 case "$1" in start)
## eureka
echo "--------eureka--------------"
nohup java -jar -Xms512m -Xmx768m $EUREKA > eureka.log &
EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$EUREKA_pid" ]
do
EUREKA_pid=`lsof -i:$EUREKA_port|grep "LISTEN"|awk '{print $2}'`
done
echo "EUREKA pid is $EUREKA_pid"
echo "--------eureka--------------"
## 启动config
echo "--------CONFIG---------------"
nohup java -jar -Xms512m -Xmx768m $CONFIG --spring.profiles.active=prod >config.log &
CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$CONFIG_pid" ]
do
CONFIG_pid=`lsof -i:$CONFIG_port|grep "LISTEN"|awk '{print $2}'`
done
echo "CONFIG pid is $CONFIG_pid"
echo "---------CONFIG-----------"
## 启动gateway
echo "--------GATEWAY---------------"
nohup java -jar -Xms768m -Xmx1g $GATEWAY >gateway.log &
GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
until [ -n "$GATEWAY_pid" ]
do
GATEWAY_pid=`lsof -i:$GATEWAY_port|grep "LISTEN"|awk '{print $2}'`
done
echo "GATEWAY pid is $GATEWAY_pid"
echo "---------GATEWAY-----------" nohup java -jar -Xms128m -Xmx128m springCloudAdminService-1.0-SNAPSHOT.jar > springCloudAdmin.log &
echo "--springCloudAdminService--"
nohup java -jar -Xms512m -Xmx2g contentService-1.0-SNAPSHOT.jar &
echo "--contentService--"
nohup java -jar -Xms512m -Xmx2g orderService-1.0-SNAPSHOT.jar &
echo "---order----"
nohup java -jar -Xms512m -Xmx2g productService-1.0-SNAPSHOT.jar &
echo "----product----"
nohup java -jar -Xms512m -Xmx2g systemService-1.0-SNAPSHOT.jar &
echo "----systemService----"
nohup java -jar -Xms512m -Xmx2g userService-1.0-SNAPSHOT.jar &
echo "----userService--------"
nohup java -jar -Xms512m -Xmx2g wechatService-1.0-SNAPSHOT.jar &
echo "----wechatService--------"
nohup java -jar -Xms512m -Xmx2g foreignService-1.0-SNAPSHOT.jar &
echo "----foreignService--------"
nohup java -jar -Xms512m -Xmx2g businessEngine-1.0-SNAPSHOT.jar &
echo "----businessEngine--------"
nohup java -jar -Xms512m -Xmx768m collocationService-1.0-SNAPSHOT.jar &
echo "----collocationService--------"
nohup java -jar -Xms512m -Xmx768m retailStoreService-1.0-SNAPSHOT.jar &
echo "----retailStoreService--------" ;;
stop) P_ID=`ps -ef | grep -w springCloudAdminService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "=== springCloudAdminService-not exists or stop success"
else
kill -9 $P_ID
echo " AdminService-killed success"
fi
P_ID=`ps -ef | grep -w contentService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "=== contentService-not exists or stop success"
else
kill -9 $P_ID
echo " contentService-killed success"
fi P_ID=`ps -ef | grep -w $GATEWAY | 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 P_ID=`ps -ef | grep -w orderService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "=== orderService-not exists or stop success"
else
kill -9 $P_ID
echo " orderService-killed success"
fi P_ID=`ps -ef | grep -w productService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "=== productService not exists or stop success"
else
kill -9 $P_ID
echo " productService killed success"
fi P_ID=`ps -ef | grep -w $CONFIG | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===CONFIG process not exists or stop success"
else
kill -9 $P_ID
echo "CONFIG killed success"
fi P_ID=`ps -ef | grep -w $EUREKA | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "===EUREKA process not exists or stop success"
else
kill -9 $P_ID
echo "EUREKA killed success"
fi
P_ID=`ps -ef | grep -w systemService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "=== systemService-not exists or stop success"
else
kill -9 $P_ID
echo " systemService- killed success"
fi P_ID=`ps -ef | grep -w userService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "userService-process not exists or stop success"
else
kill -9 $P_ID
echo "userService-killed success"
fi P_ID=`ps -ef | grep -w wechatService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "wechatService-process not exists or stop success"
else
kill -9 $P_ID
echo "wechatService-killed success"
fi P_ID=`ps -ef | grep -w foreignService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "foreignService-process not exists or stop success"
else
kill -9 $P_ID
echo "foreignService-killed success"
fi P_ID=`ps -ef | grep -w businessEngine-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "businessEngine-process not exists or stop success"
else
kill -9 $P_ID
echo "businessEngine-killed success"
fi P_ID=`ps -ef | grep -w collocationService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "collocationService-process not exists or stop success"
else
kill -9 $P_ID
echo "collocationService-killed success"
fi P_ID=`ps -ef | grep -w retailStoreService-1.0-SNAPSHOT.jar | grep -v "grep" | awk '{print $2}'`
if [ "$P_ID" == "" ]; then
echo "retailStoreService-process not exists or stop success"
else
kill -9 $P_ID
echo "retailStoreService-killed success"
fi ;;
restart)
$0 stop
sleep 15
$0 start
echo "===restart success==="
;;
view)
ps -ef|grep java|grep -v grep
;;
esac
exit 0 vue部分 BUILD_ID=DONTKILLME
npm install
npm run test
rm -rf /home/web
mv dist /home/web
npm run build
rm -rf /home/webpro
mv dist /home/webpro