fix(docker-compose.yaml): add mongo healthcheck and fix server startup race condition#313
Open
Anton-dev3306 wants to merge 1 commit into
Open
fix(docker-compose.yaml): add mongo healthcheck and fix server startup race condition#313Anton-dev3306 wants to merge 1 commit into
Anton-dev3306 wants to merge 1 commit into
Conversation
✅ Deploy Preview for quotevote canceled.
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a race condition between the
serverandmongocontainers on cold starts. Theserverservice was configured with a baredepends_on: mongo, which only waits for the MongoDB container to start — not for MongoDB to be ready to accept connections. This caused the Node.js server to attempt a connection beforemongodfinished initializing, relying onrestart: alwaysto recover silently.Changes
mongo: Docker now runsdb.adminCommand('ping')every 10 seconds to determine when MongoDB is genuinely ready.depends_onupdated onserver: Changed from a bare service dependency tocondition: service_healthy, so the server only starts after MongoDB passes its healthcheck.mongo-expressversion bump: Updated from1.0.0-alpha.4(unmaintained alpha) to1.0.2(current stable).Verification
docker compose down -v && docker compose up --force-recreateand confirmedquotevote-serverwaits for MongoDB to be healthy before starting.MongoDB Connected...log appears only after the healthcheck passes.mongo-expressUI loads correctly onhttp://localhost:8081.Related Issue
Fixes #312