#!/bin/bash # ============================================================ # Spring AI Alibaba 全功能平台 — 健康检查脚本 # 用法:bash health-check.sh # ============================================================ set -e GREEN='\033[0;32m'; RED='\033[0;31m'; YELLOW='\033[1;33m'; NC='\033[0m' pass() { echo -e " ${GREEN}✅ OK${NC} $1"; } fail() { echo -e " ${RED}❌ FAIL${NC} $1"; } echo "==============================================" echo " Spring AI Alibaba 全平台健康检查" echo " $(date '+%Y-%m-%d %H:%M:%S')" echo "==============================================" echo "" # ---- 中间件 ---- echo "[中间件层]" psql -h localhost -U sa_agent -d spring_ai_agent -c "SELECT 1" >/dev/null 2>&1 \ && pass "PostgreSQL (5432)" || fail "PostgreSQL (5432)" curl -s http://localhost:8848/nacos/v1/console/health/readiness >/dev/null 2>&1 \ && pass "Nacos (8848)" || fail "Nacos (8848)" curl -s http://localhost:9000/minio/health/live >/dev/null 2>&1 \ && pass "MinIO (9000)" || fail "MinIO (9000)" echo "" # ---- 应用 ---- echo "[应用层]" curl -s http://localhost:8080/actuator/health >/dev/null 2>&1 \ && pass "Agent Platform (8080)" || fail "Agent Platform (8080)" HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" http://localhost:8080/chatui/index.html 2>/dev/null || echo "000") if [ "$HTTP_CODE" = "200" ]; then pass "Admin Studio (/chatui)" else fail "Admin Studio (/chatui) — HTTP $HTTP_CODE" fi echo "" # ---- 外网模型 ---- echo "[模型层]" if [ -z "$DASHSCOPE_API_KEY" ]; then fail "DashScope API Key 未设置" else HTTP_CODE=$(curl -s -o /dev/null -w "%{http_code}" \ -H "Authorization: Bearer $DASHSCOPE_API_KEY" \ "https://dashscope.aliyuncs.com/api/v1/models" 2>/dev/null || echo "000") if [ "$HTTP_CODE" = "200" ]; then pass "DashScope API (阿里云百炼)" else fail "DashScope API — HTTP $HTTP_CODE" fi fi echo "" echo "==============================================" echo " 健康检查完成。" echo "=============================================="