Skip to content

fix: application does not start when postgresql is not ready in time - #949

Closed
iSaluki wants to merge 1 commit into
madeofpendletonwool:mainfrom
iSaluki:patch-1
Closed

iSaluki wants to merge 1 commit into
madeofpendletonwool:mainfrom
iSaluki:patch-1

Conversation

@iSaluki

@iSaluki iSaluki commented Jul 29, 2026

Copy link
Copy Markdown

Changes

  • This change adds a health check to the "db" service.
  • The health check uses the "pg_isready" command. This command tests if the database is ready.
  • This change adds a wait condition to the "pinepods" service. The "pinepods" service now waits until the "db" service is healthy before it starts.
  • This change adds the "restart: always" policy to the "pinepods" service and to the "valkey" service. The "db" service already had this policy.

Need for the change

  • Before this change, the "pinepods" service started as soon as the "db" container started. The "pinepods" service did not wait until the database was ready to accept connections.
  • The "pinepods" application tries to connect to the database 30 times. Each try happens about 1 second after the last try.
  • If the database is not ready within about 30 seconds, the "pinepods" application stops with an error.
  • Before this change, only the "db" service had the "restart: always" policy. The "pinepods" service did not have this policy.
  • When the "pinepods" application stopped with an error, Docker did not start it again.
  • The user then had to start the "pinepods" service again by hand.
  • This problem can happen on the first start of the stack. It can also happen when the host system is slow.
  • This change stops this problem. The "pinepods" service now waits for the database. If the "pinepods" service still fails, Docker starts it again automatically.

Copilot AI review requested due to automatic review settings July 29, 2026 09:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@iSaluki iSaluki changed the title fix: race condition that prevents application start if postgresql is slow fix: application does not start when postgresql is not ready in time Jul 29, 2026
@madeofpendletonwool

Copy link
Copy Markdown
Owner

This exposes ports and everything. I think you copied a compose into this. This is not the right approach. From a security perspective we don't want to expose postgres ports. Plus, this only works if someone actually uses compose, and people deploy pinepods in a lot of different way. Additionally, there are multiple compose examples, this touches only one.
I've expanded the wait and fixed a couple bugs in this pr: #1044
I think this will account for everything anyone should really need.

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.

3 participants