diff --git a/.github/workflows/daily-e2e-health.yaml b/.github/workflows/daily-e2e-health.yaml index 08c05d09..cc192eea 100644 --- a/.github/workflows/daily-e2e-health.yaml +++ b/.github/workflows/daily-e2e-health.yaml @@ -100,55 +100,20 @@ jobs: echo "🔗 檢查 API 健康狀態..." echo "📍 Runner: $(hostname)" echo "🌐 Target: $API_URL" - echo "📂 Working Dir: $(pwd)" - # 2026-03-29 Claude Code: 清除舊檔案避免讀到上次快取 - rm -f /tmp/health_response.txt /tmp/fallback_response.txt 2>/dev/null || true - - # 診斷網路連通性 - VIP_IP=$(echo "$API_URL" | sed -E 's|https?://([^:]+).*|\1|') - echo "🔍 Ping VIP ($VIP_IP)..." - ping -c 2 "$VIP_IP" || echo "⚠️ Ping failed (may be blocked)" - - # 2026-03-29 Claude Code: 增加 TCP 連接測試 - echo "🔌 TCP 連接測試 ($VIP_IP:32334)..." - timeout 5 bash -c "cat < /dev/null > /dev/tcp/$VIP_IP/32334" && echo "✅ TCP 連接成功" || echo "⚠️ TCP 連接失敗" - - # 嘗試連線 (正確路徑: /api/v1/health) - echo "🔗 Curl health endpoint (verbose)..." - # 2026-03-29 Claude Code: 改用 verbose 模式輸出診斷資訊 - curl -v --connect-timeout 15 "$API_URL/api/v1/health" -o /tmp/health_response.txt 2>&1 | head -30 || true - - # 2026-03-29 Claude Code: 重新取得 HTTP code (簡化) - HTTP_CODE=$(curl -s -w "%{http_code}" -o /dev/null --connect-timeout 15 "$API_URL/api/v1/health" 2>/dev/null) + # 2026-03-29 Claude Code: 簡化版健康檢查,避免 SIGPIPE 問題 + HTTP_CODE=$(curl -s -w "%{http_code}" -o /tmp/health_response.txt --connect-timeout 15 "$API_URL/api/v1/health" 2>/dev/null) echo "📊 HTTP Code: [$HTTP_CODE]" if [ "$HTTP_CODE" = "200" ]; then - echo "✅ API 可用: $API_URL (HTTP $HTTP_CODE)" + echo "✅ API 可用: $API_URL" cat /tmp/health_response.txt + echo "" echo "working_api_url=$API_URL" >> $GITHUB_OUTPUT else echo "❌ API 無法連線: $API_URL (HTTP $HTTP_CODE)" - echo "📋 Response (如有):" + echo "📋 Response:" cat /tmp/health_response.txt 2>/dev/null || echo "(empty)" - - # 2026-03-29 Claude Code: 使用 nc 直接測試 - echo "🔧 使用 nc 直接測試..." - echo -e "GET /api/v1/health HTTP/1.1\r\nHost: $VIP_IP:32334\r\n\r\n" | nc -w5 $VIP_IP 32334 | head -5 || echo "nc 測試失敗" - - # 嘗試備用端點 (node 121 直連) - FALLBACK_URL="http://192.168.0.121:32334" - echo "🔄 嘗試備用端點: $FALLBACK_URL" - FALLBACK_CODE=$(curl -s -w "%{http_code}" -o /dev/null --connect-timeout 10 "$FALLBACK_URL/api/v1/health" 2>/dev/null) - echo " 備用結果: HTTP $FALLBACK_CODE" - - if [ "$FALLBACK_CODE" = "200" ]; then - echo "✅ 備用端點可用,VIP 可能有問題" - curl -s "$FALLBACK_URL/api/v1/health" - echo "working_api_url=$FALLBACK_URL" >> $GITHUB_OUTPUT - exit 0 # 備用成功,不算失敗 - fi - exit 1 fi