feat(admin): 添加用户管理相关文件
添加用户管理视图、API和状态管理文件
This commit is contained in:
Executable
+125
@@ -0,0 +1,125 @@
|
||||
#!/bin/bash
|
||||
|
||||
API_DIR="$(cd "$(dirname "$0")/.." && pwd)/everything-is-suitable-api/everything-is-suitable-app"
|
||||
PID_FILE="/tmp/api-service.pid"
|
||||
LOG_FILE="/tmp/api-service.log"
|
||||
PORT=${API_PORT:-8080}
|
||||
PROFILE=${API_PROFILE:-test}
|
||||
|
||||
start_api() {
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if ps -p "$PID" > /dev/null 2>&1; then
|
||||
echo "API 服务已在运行中 (PID: $PID)"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "正在启动 API 服务 (profile: $PROFILE, port: $PORT)..."
|
||||
cd "$API_DIR"
|
||||
|
||||
nohup mvn spring-boot:run \
|
||||
-Dspring-boot.run.profiles="$PROFILE" \
|
||||
-Dspring-boot.run.arguments="--server.port=$PORT" \
|
||||
> "$LOG_FILE" 2>&1 &
|
||||
|
||||
echo $! > "$PID_FILE"
|
||||
PID=$(cat "$PID_FILE")
|
||||
|
||||
echo "等待服务启动..."
|
||||
MAX_WAIT=120
|
||||
WAITED=0
|
||||
while [ $WAITED -lt $MAX_WAIT ]; do
|
||||
if curl -s "http://localhost:$PORT/actuator/health" > /dev/null 2>&1; then
|
||||
echo "✅ API 服务已成功启动 (PID: $PID, Port: $PORT)"
|
||||
echo "日志文件: $LOG_FILE"
|
||||
return 0
|
||||
fi
|
||||
sleep 2
|
||||
WAITED=$((WAITED + 2))
|
||||
printf "\r等待中... %d秒 " $WAITED
|
||||
done
|
||||
|
||||
echo ""
|
||||
echo "❌ API 服务启动超时"
|
||||
echo "查看日志: tail -100 $LOG_FILE"
|
||||
stop_api
|
||||
return 1
|
||||
}
|
||||
|
||||
stop_api() {
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if ps -p "$PID" > /dev/null 2>&1; then
|
||||
echo "正在停止 API 服务 (PID: $PID)..."
|
||||
kill "$PID" 2>/dev/null
|
||||
sleep 2
|
||||
if ps -p "$PID" > /dev/null 2>&1; then
|
||||
kill -9 "$PID" 2>/dev/null
|
||||
fi
|
||||
rm -f "$PID_FILE"
|
||||
echo "✅ API 服务已停止"
|
||||
else
|
||||
echo "API 服务未运行"
|
||||
rm -f "$PID_FILE"
|
||||
fi
|
||||
else
|
||||
echo "未找到 PID 文件,API 服务可能未运行"
|
||||
fi
|
||||
}
|
||||
|
||||
status_api() {
|
||||
if [ -f "$PID_FILE" ]; then
|
||||
PID=$(cat "$PID_FILE")
|
||||
if ps -p "$PID" > /dev/null 2>&1; then
|
||||
echo "API 服务运行中 (PID: $PID, Port: $PORT)"
|
||||
echo "健康检查:"
|
||||
curl -s "http://localhost:$PORT/actuator/health" | jq . 2>/dev/null || \
|
||||
curl -s "http://localhost:$PORT/actuator/health"
|
||||
return 0
|
||||
fi
|
||||
fi
|
||||
echo "API 服务未运行"
|
||||
return 1
|
||||
}
|
||||
|
||||
logs_api() {
|
||||
if [ -f "$LOG_FILE" ]; then
|
||||
echo "显示最近100行日志 (Ctrl+C 退出):"
|
||||
tail -100 -f "$LOG_FILE"
|
||||
else
|
||||
echo "日志文件不存在: $LOG_FILE"
|
||||
fi
|
||||
}
|
||||
|
||||
case "${1:-}" in
|
||||
start)
|
||||
start_api
|
||||
;;
|
||||
stop)
|
||||
stop_api
|
||||
;;
|
||||
restart)
|
||||
stop_api
|
||||
sleep 3
|
||||
start_api
|
||||
;;
|
||||
status)
|
||||
status_api
|
||||
;;
|
||||
logs)
|
||||
logs_api
|
||||
;;
|
||||
*)
|
||||
echo "用法: $0 {start|stop|restart|status|logs}"
|
||||
echo ""
|
||||
echo "环境变量:"
|
||||
echo " API_PORT - API 服务端口 (默认: 8080)"
|
||||
echo " API_PROFILE - Spring Profile (默认: test)"
|
||||
echo ""
|
||||
echo "示例:"
|
||||
echo " API_PORT=9090 $0 start # 在端口9090启动"
|
||||
echo " $0 logs # 查看日志"
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
Reference in New Issue
Block a user