#!/bin/bash # 健康检查 # 用法: bash health.sh CONFIG_FILE="$HOME/.openclaw/cloud-deploy.json" if [ ! -f "$CONFIG_FILE" ]; then echo "配置文件不存在,正在初始化..." bash "$(dirname "$0")/init-config.sh" fi API_URL=$(python3 -c "import json; print(json.load(open('$CONFIG_FILE'))['apiUrl'])") RESPONSE=$(curl -s --max-time 10 "$API_URL/health" 2>/dev/null) if [ -z "$RESPONSE" ]; then echo "❌ API 不可达: $API_URL" exit 1 fi echo "$RESPONSE" | python3 -m json.tool 2>/dev/null || echo "$RESPONSE"