Files
route-commerce/.gitea/workflows
tyler 7ddb06d7bd
Deploy to route.crispygoat.com / deploy (push) Failing after 13s
Build / build (push) Has been cancelled
fix(deploy): harden port-freeing against TOCTOU bind failures
The Start Docker stack step was racing itself: docker compose down
errors were silently swallowed (|| true), leaving the previous
postgrest container in a half-torn-down state. fuser -k would kill
the listener, ss would see 3011 as free, the script would pick 3011,
and then docker compose up would fail to bind because the port was
in TIME_WAIT (or a stale docker-proxy listener was still holding it).

Three changes:

1. Don't swallow docker compose down errors. If the previous stack
   isn't actually down, fail loudly so we can investigate.
2. Explicitly remove any surviving route_commerce_postgrest container
   and kill any leftover docker-proxy listeners for ports 3011-3013
   before picking a port.
3. Verify the postgrest container is gone after the cleanup. If it's
   not, exit 1 instead of continuing into a guaranteed bind failure.
4. Port-picking loop now retries with a 1s sleep on each port (handles
   TIME_WAIT settling), and uses a stricter ss grep that matches
   127.0.0.1:<port> anchored on whitespace to avoid false positives
   from substring matches (e.g. :30110 matching :3011).

Reproduces the failure mode from the run on 2026-06-06: postgrest
failed to bind 127.0.0.1:3011 with 'address already in use' even
though the script had just reported it as free.
2026-06-06 00:55:38 +00:00
..