#!/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/ruoyi-app-api-pinyin*.jar
cp $currentLocation/ruoyi-app-api-zidian/target/ruoyi-app-api-zidian.jar /opt/tempjar/ruoyi-app-api-pinyin-${BUILD_TIMESTAMP}.jar

echo "殺掉舊的進程" 
ps -ef | grep java | grep -v grep |grep 'ruoyi-app-api-pinyin' | awk '{print "kill -9 "  $2}'  | sh

sleep 2
echo "開始重慶" 

nohup java -javaagent:/opt/apache-skywalking-apm-bin/agent/skywalking-agent.jar=agent.service_name=ruoyi-app-api-pinyin,collector.backend_service=127.0.0.1:11800  -jar -Xmx2g -Xms2g  -XX:+UseConcMarkSweepGC /opt/tempjar/ruoyi-app-api-pinyin-${BUILD_TIMESTAMP}.jar --spring.profiles.active=devPinYin --server.port=30300 --nacos.config.server-addr=8.210.212.227:1885 > /opt/tempjar/log-app-api-pinyin.log  & 

tail -f /opt/tempjar/log-app-api-pinyin.log &

sleep 60
