diff --git a/.gitea/workflows/deploy.yml b/.gitea/workflows/deploy.yml index 2dc654d..e5bc4f9 100644 --- a/.gitea/workflows/deploy.yml +++ b/.gitea/workflows/deploy.yml @@ -175,22 +175,31 @@ jobs: # Poll instead of guessing how long startup takes. The old fixed # "sleep 3" then single curl raced whenever startup ran long, and # failed the deploy with a bare "connection refused" on a service - # that came up healthy a second later. This exits as soon as the app - # answers, so a fast start costs nothing. + # that came up healthy a second later. + # + # Record the result and fall through rather than exiting early: this + # script is piped to the remote shell's stdin, so an "exit 0" in the + # middle can close the channel while ssh is still writing the rest, + # which surfaces as a broken pipe and fails the step even though the + # check passed. Only the very last statement may exit non-zero. + healthy=0 for i in $(seq 1 60); do if curl -fsS http://127.0.0.1:8998/api/v1/health > /dev/null 2>&1; then + healthy=1 echo "✓ signalplatform deployed — healthy after ${i}s" - exit 0 + break fi sleep 1 done - # Still down after a minute: this is a real failure, so leave enough - # behind to diagnose it without a second deploy. - echo "✗ health check failed: no response on :8998 after 60s" - sudo systemctl status signalplatform.service --no-pager -l || true - journalctl -u signalplatform.service -n 80 --no-pager || true - exit 1 + # Still down after a minute: a real failure, so leave enough behind + # to diagnose it without running a second deploy to go looking. + if [ "$healthy" -ne 1 ]; then + echo "✗ health check failed: no response on :8998 after 60s" + sudo systemctl status signalplatform.service --no-pager -l || true + journalctl -u signalplatform.service -n 80 --no-pager || true + exit 1 + fi REMOTE_SCRIPT - name: Clean up SSH key