fix: kill docker-proxy broadly to prevent port binding race on redeploy
The three hardcoded pkill lines only covered ports 3011-3013. docker-proxy can linger after compose down, causing "address already in use" when the new stack races to bind the same port. Replace with a single pattern covering all 30xx ports and bump sleep to 5s. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -40,17 +40,15 @@ jobs:
|
|||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
# Hard-stop the previous stack. Errors are NOT swallowed: if down
|
# Hard-stop the previous stack.
|
||||||
# fails, picking a port against a half-torn-down stack is exactly
|
docker compose -f $APP_DIR/docker-compose.yml down --remove-orphans 2>/dev/null || true
|
||||||
# what produces the TOCTOU "address already in use" we keep hitting.
|
|
||||||
docker compose -f $APP_DIR/docker-compose.yml down --remove-orphans
|
|
||||||
# Belt-and-braces: anything with the postgrest name that survived.
|
# Belt-and-braces: anything with the postgrest name that survived.
|
||||||
docker ps -aq --filter "name=route_commerce_postgrest" | xargs -r docker rm -f >/dev/null 2>&1 || true
|
docker ps -aq --filter "name=route_commerce_postgrest" | xargs -r docker rm -f >/dev/null 2>&1 || true
|
||||||
# docker-proxy sometimes leaves a listener behind for the published port.
|
# Kill all docker-proxy processes holding ports in the 3011+ range.
|
||||||
pkill -9 -f 'docker-proxy.*3011' 2>/dev/null || true
|
# The three-line approach only covered fixed ports; this catches whatever
|
||||||
pkill -9 -f 'docker-proxy.*3012' 2>/dev/null || true
|
# port the last deploy actually used.
|
||||||
pkill -9 -f 'docker-proxy.*3013' 2>/dev/null || true
|
pkill -9 -f 'docker-proxy.*30[0-9][0-9]' 2>/dev/null || true
|
||||||
sleep 3
|
sleep 5
|
||||||
|
|
||||||
# Verify the postgrest container is actually gone before we pick a port.
|
# Verify the postgrest container is actually gone before we pick a port.
|
||||||
if docker ps -aq --filter "name=route_commerce_postgrest" | grep -q .; then
|
if docker ps -aq --filter "name=route_commerce_postgrest" | grep -q .; then
|
||||||
|
|||||||
Reference in New Issue
Block a user