fix(cd): 健康檢查改用 break+flag,修復 SSH heredoc exit 0 SIGPIPE
在 SSH heredoc 裡 exit 0 會讓遠端 shell 退出,但本地 SSH 進程 試圖繼續餵剩餘 heredoc 內容時收到 SIGPIPE,exitcode 變 1。 改用 HEALTH_PASS flag + break,heredoc 自然結束,避免 SIGPIPE。 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -206,18 +206,23 @@ jobs:
|
||||
echo "✅ 部署完成"
|
||||
|
||||
# Health Check (同一 SSH session,省去再次握手)
|
||||
# 2026-04-01 Claude Code: 改用 break+flag,避免 exit 0 在 heredoc 引發 SIGPIPE
|
||||
sleep 10
|
||||
HEALTH_PASS=0
|
||||
for i in 1 2 3; do
|
||||
HTTP_CODE=$(curl -s -w "%{http_code}" -o /dev/null --connect-timeout 10 "http://localhost:32334/api/v1/health")
|
||||
if [ "$HTTP_CODE" = "200" ]; then
|
||||
echo "✅ API 健康檢查通過"
|
||||
exit 0
|
||||
HEALTH_PASS=1
|
||||
break
|
||||
fi
|
||||
echo "⏳ 嘗試 #$i: HTTP $HTTP_CODE,等待 10s..."
|
||||
sleep 10
|
||||
done
|
||||
echo "❌ API 健康檢查失敗"
|
||||
exit 1
|
||||
if [ "$HEALTH_PASS" = "0" ]; then
|
||||
echo "❌ API 健康檢查失敗"
|
||||
exit 1
|
||||
fi
|
||||
DEPLOY
|
||||
|
||||
- name: Notify Health Check Success
|
||||
|
||||
Reference in New Issue
Block a user