#!/bin/bash

# 项目路径
PROJECT_PATH=/home/centos/okki-oms/jeecg-boot
 
# 进入项目目录
cd $PROJECT_PATH
 
# 清理Maven项目
mvn clean
 
# 打包Maven项目
mvn package -Dmaven.test.skip=true
 
# 检查包是否生成成功
if [ -f "$PROJECT_PATH/jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.6.3.jar" ]; then
    echo "微服务包生成成功"
else
    echo "微服务包生成失败"
    exit 1
fi

# 检查Java进程是否存在
PID=$(ps -ef | grep jeecg-system-start-3.6.3.jar | grep -v grep | awk '{print $2}')
if [[ -n ${PID} ]]; then
echo "Java process is running, PID is ${PID}. Killing..."
kill -9 ${PID}
fi
nohup java -jar "$PROJECT_PATH/jeecg-module-system/jeecg-system-start/target/jeecg-system-start-3.6.3.jar" --spring.profiles.active=prod >/home/centos/okki-oms/jeecg-boot/logs/out.log &