#!/bin/bash
BUILD_ID=dontKillMe
java -version

BUILD_TIMESTAMP=`date +'%Y-%m-%d_%H-%M-%S'`
echo $BUILD_TIMESTAMP
echo ${BUILD_TIMESTAMP}

echo "編譯完了" 

export JAVA_HOME=/opt/jdk
export JRE_HOME=/opt/jdk/jre
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar


java -version
pwd
currentLocation=$(pwd)
echo $currentLocation

echo "編譯完了" 
mkdir -p /opt/tempjar
rm -rf /opt/tempjar/java-houtai-manage-jiegou*.jar
cp $currentLocation/ruoyi-admin/target/ruoyi-admin.jar /opt/tempjar/java-houtai-manage-jiegou-${BUILD_TIMESTAMP}.jar
echo "殺掉舊的進程" 
ps -ef | grep java | grep -v grep |grep 'java-houtai-manage-jiegou' | awk '{print "kill -9 "  $2}'  | sh
sleep 2
echo "開始重慶" 





nohup java  -javaagent:/opt/apache-skywalking-apm-bin/agent/skywalking-agent.jar=agent.service_name=java-houtai-manage-jiegou,collector.backend_service=127.0.0.1:11800   -jar -Xmx2g -Xms2g -XX:+UseConcMarkSweepGC /opt/tempjar/java-houtai-manage-jiegou-${BUILD_TIMESTAMP}.jar --spring.profiles.active=devJieGou --server.port=30401 --nacos.config.server-addr=8.210.212.227:1886 >/opt/tempjar/log-java-houtai-manage-jiegou.log & 

tail -f /opt/tempjar/log-java-houtai-manage-jiegou.log &

sleep 55

