Skip to content

Make Postgres wait timeout configurable#214

Merged
medihack merged 2 commits intomainfrom
configurable-postgres-wait-timeout
Apr 9, 2026
Merged

Make Postgres wait timeout configurable#214
medihack merged 2 commits intomainfrom
configurable-postgres-wait-timeout

Conversation

@NumericalAdvantage
Copy link
Copy Markdown
Collaborator

@NumericalAdvantage NumericalAdvantage commented Apr 9, 2026

Summary

  • Replace hard-coded wait-for-it timeouts with a configurable WAIT_POSTGRES_TIMEOUT environment variable across all docker-compose files
  • Default is 180 seconds (up from 120s in prod, 60s in dev), which gives slower hardware comfortable headroom
  • Users can override via .env without modifying compose files

Closes #212

Test plan

  • Verify docker compose config correctly interpolates the default (180s) when WAIT_POSTGRES_TIMEOUT is unset
  • Verify setting WAIT_POSTGRES_TIMEOUT=300 in .env overrides all wait-for-it calls
  • Confirm containers start normally with both dev and prod compose files

🤖 Generated with Claude Code

Summary by CodeRabbit

  • Chores
    • Added configurable PostgreSQL startup timeout. The system now allows customization of the maximum wait time for PostgreSQL availability during container initialization via the WAIT_POSTGRES_TIMEOUT environment variable (defaults to 180 seconds).

… var

Replace hard-coded wait-for-it timeouts with a configurable
WAIT_POSTGRES_TIMEOUT environment variable (default: 180s) across all
docker-compose files. This allows users on slower hardware (e.g. NAS
devices) to adjust the timeout without modifying the compose files.

Closes #212
@coderabbitai
Copy link
Copy Markdown

coderabbitai bot commented Apr 9, 2026

📝 Walkthrough

Walkthrough

The changes parameterize the PostgreSQL readiness timeout across Docker Compose configurations (dev and prod) by replacing hardcoded values with an environment variable WAIT_POSTGRES_TIMEOUT, defaulting to 180 seconds. This applies to database initialization waits in the web, init, default_worker, and llm_worker services.

Changes

Cohort / File(s) Summary
Docker Compose Configuration
docker-compose.dev.yml, docker-compose.prod.yml
Parameterized Postgres readiness timeout from hardcoded values (60s for workers, 120s for init) to configurable ${WAIT_POSTGRES_TIMEOUT:-180} environment variable, affecting startup sequencing for database initialization and background workers.
Environment Configuration
example.env
Added WAIT_POSTGRES_TIMEOUT=180 environment variable with inline documentation describing its purpose as the maximum wait duration for PostgreSQL availability during container startup.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Poem

🐰 A timeout was hardcoded, rigid and tight,
Until Docker complained—"Let me tweak this, alright!"
Now WAIT_POSTGRES_TIMEOUT dances with grace,
Environment variables taking their place. 🐘✨

🚥 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 'Make Postgres wait timeout configurable' accurately and concisely describes the main change: parameterizing hard-coded wait timeouts with an environment variable across docker-compose files.
Linked Issues check ✅ Passed The PR fully addresses issue #212 by making the Postgres wait timeout configurable via the WAIT_POSTGRES_TIMEOUT environment variable, allowing users to adjust timeouts without modifying source code.
Out of Scope Changes check ✅ Passed All changes are directly scoped to issue #212: parameterizing wait-for-it timeouts in docker-compose files and documenting the new environment variable with a sensible default.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ 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 configurable-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 and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@docker-compose.dev.yml`:
- Line 55: The wait-for-it invocations use unquoted variable expansion for the
timeout; update every bash -c call that passes ${WAIT_POSTGRES_TIMEOUT:-180}
(e.g., the wait-for-it -s postgres.local:5432 -t ${WAIT_POSTGRES_TIMEOUT:-180}
occurrences) to quote the expansion ("${WAIT_POSTGRES_TIMEOUT:-180}") so
word-splitting and special characters are preserved; apply this change to all
matching wait-for-it calls across the compose files mentioned.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 0cb0137f-ee5c-471d-ab4c-53dab37b7548

📥 Commits

Reviewing files that changed from the base of the PR and between 5e48cfd and 22b377a.

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

Comment thread docker-compose.dev.yml
command: >
bash -c "
wait-for-it -s postgres.local:5432 -t 60 &&
wait-for-it -s postgres.local:5432 -t ${WAIT_POSTGRES_TIMEOUT:-180} &&
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Verify unquoted WAIT_POSTGRES_TIMEOUT usage in compose files.
rg -nP 'wait-for-it\s+-s\s+postgres\.local:5432\s+-t\s+\$\{WAIT_POSTGRES_TIMEOUT:-180\}' --iglob 'docker-compose*.yml'

Repository: openradx/radis

Length of output: 690


🏁 Script executed:

cat -n docker-compose.dev.yml | sed -n '50,85p'

Repository: openradx/radis

Length of output: 1461


🏁 Script executed:

cat -n docker-compose.prod.yml | sed -n '25,80p'

Repository: openradx/radis

Length of output: 1880


Quote WAIT_POSTGRES_TIMEOUT in all docker-compose shell commands.

Unquoted variable expansion in bash -c can cause word-splitting and argument parsing failures if the environment variable contains spaces or special characters. Quote the timeout argument at each callsite.

Affected locations
  • docker-compose.dev.yml: lines 55, 72, 81
  • docker-compose.prod.yml: lines 29, 64, 74
Suggested patch
-        wait-for-it -s postgres.local:5432 -t ${WAIT_POSTGRES_TIMEOUT:-180} &&
+        wait-for-it -s postgres.local:5432 -t "${WAIT_POSTGRES_TIMEOUT:-180}" &&

Apply to all 6 occurrences.

📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
wait-for-it -s postgres.local:5432 -t ${WAIT_POSTGRES_TIMEOUT:-180} &&
wait-for-it -s postgres.local:5432 -t "${WAIT_POSTGRES_TIMEOUT:-180}" &&
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@docker-compose.dev.yml` at line 55, The wait-for-it invocations use unquoted
variable expansion for the timeout; update every bash -c call that passes
${WAIT_POSTGRES_TIMEOUT:-180} (e.g., the wait-for-it -s postgres.local:5432 -t
${WAIT_POSTGRES_TIMEOUT:-180} occurrences) to quote the expansion
("${WAIT_POSTGRES_TIMEOUT:-180}") so word-splitting and special characters are
preserved; apply this change to all matching wait-for-it calls across the
compose files mentioned.

Copy link
Copy Markdown

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request introduces a configurable timeout for waiting for the PostgreSQL database to become available during container startup. Hardcoded timeout values in both development and production Docker Compose files have been replaced with a new environment variable, WAIT_POSTGRES_TIMEOUT, which defaults to 180 seconds. The example.env file was also updated to include this variable along with documentation for its use on low-power hardware. I have no feedback to provide.

Remove PostgreSQL wait timeout configuration.
@medihack medihack merged commit f9f525b into main Apr 9, 2026
2 checks passed
@medihack medihack deleted the configurable-postgres-wait-timeout branch April 9, 2026 14:40
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.

Radis-init worker times out while waiting for Postgres

2 participants