Skip to content

Commit 2b74510

Browse files
owineclaude
andcommitted
feat(health-check): include health check output in failure logs
Show health check status, failing streak, and last 3 check outputs with exit codes to help diagnose why health checks are failing. Only displays health check section if container has one configured. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent e5d142c commit 2b74510

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

scripts/deployment/health-check.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,17 @@ set +e
196196
echo ""
197197
echo "🔸 Container: $name ($service) - $reason"
198198
echo "────────────────────────────────────────────────────────────────"
199-
# Use --tail to limit output and --timestamps for better debugging
199+
200+
# Show health check output (last 3 checks) if health check exists
201+
has_healthcheck=$(docker inspect --format='{{if .State.Health}}yes{{else}}no{{end}}' "$name" 2>/dev/null) || has_healthcheck="no"
202+
if [ "$has_healthcheck" = "yes" ]; then
203+
echo "📍 Health Check Output:"
204+
docker inspect --format='Status: {{.State.Health.Status}} | FailingStreak: {{.State.Health.FailingStreak}}{{if .State.Health.Log}}{{range $i, $log := .State.Health.Log}}{{if lt $i 3}}
205+
[Exit={{.ExitCode}}] {{.Output}}{{end}}{{end}}{{end}}' "$name" 2>/dev/null || echo " Could not retrieve health output"
206+
echo ""
207+
fi
208+
209+
echo "📋 Container Logs (last $log_lines lines):"
200210
docker logs --tail "$log_lines" --timestamps "$name" 2>&1 || echo " ⚠️ Could not retrieve logs for $name"
201211
echo "────────────────────────────────────────────────────────────────"
202212
fi

0 commit comments

Comments
 (0)