#!/bin/bash
# hzhub-monitor-admin 启动脚本

cd "$(dirname "$0")"

# 检查 jar 是否存在
JAR="target/hzhub-monitor-admin.jar"
if [ ! -f "$JAR" ]; then
  echo "构建中..."
  cd ../../..
  cd hzhub-extend/hzhub-monitor-admin
  mvn clean package -DskipTests -q
  cd "$(dirname "$0")"
fi

mkdir -p logs

echo "Starting hzhub-monitor-admin (port 9090)..."

nohup java -jar target/hzhub-monitor-admin.jar > logs/monitor-admin.log 2>&1 &
echo $! > logs/monitor-admin.pid
echo "hzhub-monitor-admin started with PID $(cat logs/monitor-admin.pid)"
echo "View logs with: tail -f logs/monitor-admin.log"
echo "Access: http://localhost:9090/admin"
echo "Default credentials: ruoyi / 123456"
