first commit

This commit is contained in:
2026-04-23 09:58:47 +08:00
commit 448e078d99
49 changed files with 5188 additions and 0 deletions

66
scripts/check_health.sh Normal file
View File

@@ -0,0 +1,66 @@
#!/usr/bin/env bash
# ══════════════════════════════════════════════════
# check_health.sh
# 检查所有服务的健康状态和资源使用
# 用法bash scripts/check_health.sh
# ══════════════════════════════════════════════════
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJECT_DIR="$(dirname "$SCRIPT_DIR")"
cd "$PROJECT_DIR"
GREEN='\033[0;32m'; RED='\033[0;31m'; YELLOW='\033[1;33m'; BLUE='\033[0;34m'; NC='\033[0m'
echo ""
echo -e "${BLUE}══════════════════════════════════════════${NC}"
echo -e "${BLUE} 服务健康检查报告${NC}"
echo -e "${BLUE}══════════════════════════════════════════${NC}"
echo ""
# Docker 服务状态
echo -e "${BLUE}【Docker Compose 服务状态】${NC}"
docker compose ps --format "table {{.Service}}\t{{.Status}}\t{{.Ports}}"
echo ""
# HTTP 端点检查
echo -e "${BLUE}【HTTP 健康端点】${NC}"
check_http() {
local name=$1; local url=$2
if curl -sf --max-time 5 "$url" > /dev/null 2>&1; then
echo -e " ${GREEN}[OK]${NC} $name ($url)"
else
echo -e " ${RED}[FAIL]${NC} $name ($url)"
fi
}
check_http "API 网关" "http://localhost/health"
check_http "业务后端" "http://localhost:8000/health"
check_http "嵌入服务" "http://localhost:8010/health"
check_http "解析服务" "http://localhost:8011/health"
check_http "Milvus" "http://localhost:9091/healthz"
check_http "Neo4j" "http://localhost:7474"
echo ""
# 资源使用
echo -e "${BLUE}【容器资源使用】${NC}"
docker stats --no-stream --format \
"table {{.Name}}\t{{.CPUPerc}}\t{{.MemUsage}}\t{{.MemPerc}}" \
2>/dev/null | head -15
echo ""
# 磁盘使用
echo -e "${BLUE}【磁盘使用】${NC}"
df -h . | tail -1 | awk '{print " 项目目录:已用 "$3",可用 "$4"" $5 " 使用率)"}'
docker system df 2>/dev/null | head -6
echo ""
# LLM 配置检查
echo -e "${BLUE}【LLM API 配置】${NC}"
source .env 2>/dev/null || true
if [[ -n "${DEEPSEEK_API_KEY:-}" ]]; then
echo -e " ${GREEN}[OK]${NC} DeepSeek API Key 已配置"
elif [[ -n "${DASHSCOPE_API_KEY:-}" ]]; then
echo -e " ${GREEN}[OK]${NC} DashScope (Qwen) API Key 已配置"
else
echo -e " ${YELLOW}[WARN]${NC} 未配置 LLM API KeyLLM 功能不可用)"
fi
echo ""