Skip to content

Make the Postgres startup wait timeout configurable - #383

Open
NumericalAdvantage wants to merge 2 commits into
mainfrom
postgres-wait-timeout
Open

Make the Postgres startup wait timeout configurable#383
NumericalAdvantage wants to merge 2 commits into
mainfrom
postgres-wait-timeout

Conversation

@NumericalAdvantage

@NumericalAdvantage NumericalAdvantage commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Replaces #323, which was opened in April and had drifted behind main. Same change, redone cleanly against current main — and it now covers the eight Postgres waits present today (the April branch only knew about six; more worker services have been added since).

Companion to openradx/adit-radis-shared#225.

The web, worker and receiver containers wait a hard-coded 60 seconds for Postgres to accept connections. On a slow or loaded host that is not always enough, and the only way to change it was to edit committed compose files.

wait-for-it -t 60 becomes wait-for-it -t ${WAIT_POSTGRES_TIMEOUT:-180} for the Postgres waits in the dev and prod compose files, and the variable is documented in example.env. The unrelated orthanc1 and init.local waits are deliberately left alone.

Verified with docker compose config:

Case Rendered
unset (default) -t 180
WAIT_POSTGRES_TIMEOUT=300 -t 300
orthanc1 / init.local -t 60 / -t 300 (unchanged)

Summary by CodeRabbit

  • Bug Fixes
    • Improved application startup reliability by allowing more time for PostgreSQL to become ready.
    • Added a configurable startup wait timeout, defaulting to 180 seconds.
    • Applied the setting consistently across development and production services.

The web, worker and receiver containers waited a hard-coded 60 seconds for
Postgres to accept connections, which is not always enough on a slow or loaded
host and could only be changed by editing committed compose files.

Replace the hard-coded value with ${WAIT_POSTGRES_TIMEOUT:-180} for the eight
Postgres waits in the dev and prod compose files and document the variable in
example.env. The unrelated orthanc1 and init.local waits are left as is.
@coderabbitai

coderabbitai Bot commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

Development and production Compose services now use the configurable WAIT_POSTGRES_TIMEOUT setting for PostgreSQL readiness checks. The default value is 180 seconds. The setting is documented in example.env.

Changes

PostgreSQL startup timeout configuration

Layer / File(s) Summary
Timeout setting and Compose integration
example.env, docker-compose.dev.yml, docker-compose.prod.yml
WAIT_POSTGRES_TIMEOUT defaults to 180 seconds and replaces fixed 60-second PostgreSQL readiness timeouts across web, initialization, and worker services.

Estimated code review effort: 1 (Trivial) | ~5 minutes

Suggested reviewers: medihack

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the main change: making the PostgreSQL startup wait timeout configurable.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch postgres-wait-timeout

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
example.env (1)

103-105: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Include the production init service in the description.

docker-compose.prod.yml Line 26 also uses WAIT_POSTGRES_TIMEOUT for the init service. Update this comment so operators know that the setting controls production initialization as well.

Proposed documentation update
-# Seconds the web and worker containers wait for Postgres to accept connections
+# Seconds the web, init, and worker containers wait for Postgres to accept connections
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@example.env` around lines 103 - 105, Update the comment above
WAIT_POSTGRES_TIMEOUT to state that the timeout applies to the web, worker, and
production init containers while they wait for Postgres connections before
startup or initialization proceeds.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@example.env`:
- Around line 103-105: Update the comment above WAIT_POSTGRES_TIMEOUT to state
that the timeout applies to the web, worker, and production init containers
while they wait for Postgres connections before startup or initialization
proceeds.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 39da5980-e0a5-4c87-8c4d-ddbc02402046

📥 Commits

Reviewing files that changed from the base of the PR and between c110e5e and 36d9161.

📒 Files selected for processing (3)
  • docker-compose.dev.yml
  • docker-compose.prod.yml
  • example.env

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant