Gate psql-app startup on Postgres health (fix cold-boot race)

On a cold boot all containers start together; psql-app finishes its
RPKI/IRR/DBIP setup and opens its single Postgres connection while the
DB is still initialising -> "the database system is starting up" ->
ConsumerApp.main throws and the consumer dies. The container does NOT
exit (the wrapper keeps cron/rsyslog alive), so restart: unless-stopped
never fires and the consumer stays dead silently.

Add depends_on psql: condition: service_healthy (plus kafka) so Compose
holds psql-app until Postgres passes its pg_isready healthcheck.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
sam 2026-05-19 13:53:09 -07:00
parent d7084aba54
commit 22d26f0e0f

View File

@ -199,6 +199,16 @@ services:
psql-app: psql-app:
restart: unless-stopped restart: unless-stopped
container_name: obmp-psql-app container_name: obmp-psql-app
# Gate startup on Postgres being ready. psql-app's consumer connects to
# Postgres once at startup and, if it loses the cold-boot race (DB still
# initialising -> "the database system is starting up"), ConsumerApp.main
# throws and the consumer dies -- and the container does NOT exit, so
# restart: unless-stopped never fires. service_healthy avoids the race.
depends_on:
psql:
condition: service_healthy
kafka:
condition: service_started
# No healthcheck — the consumer exposes no health port; Docker's # No healthcheck — the consumer exposes no health port; Docker's
# restart-on-exit covers process death. # restart-on-exit covers process death.
image: openbmp/psql-app:2.2.2 image: openbmp/psql-app:2.2.2