-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Healthchecks to ensure django container kicks off only after db container is healthy. #23
base: master
Are you sure you want to change the base?
Conversation
…ff django container Setting up health checks for postgres db to be ready before kicking off django container
Removed version tag - redundant as per docker.
@inistor, @matthill, @denisgolius, @k0ste : Created this PR to let django container start only after db container is healthy. Please review and merge as you see fit! |
depends_on: | ||
- "django" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I understand the architecture correctly, the worker
container depends directly on the DB, not on django
- so its depends_on
directive should be similar to django
's.
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic: this PR should only perform changes related to its purpose, omitting styling or typos - it's easier to follow
@@ -1,4 +1,3 @@ | |||
version: "3.9" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pedantic: this PR should only perform changes related to its purpose, omitting styling or typos - it's easier to follow
healthcheck: | ||
test: [ "CMD-SHELL", "sh -c 'pg_isready -U $${POSTGRES_USER} -d $${POSTGRES_DB}'" ] | ||
interval: 10s | ||
timeout: 5s | ||
retries: 5 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A simpler healthcheck directive might be better:
healthcheck:
test: pg_isready
interval: 5s
See this PR.
Prior to this proposed fix, django container kicks off as soon as the db container is created. This ends up in these errors on the django container startup as shown in the attached file.
all_containers_launch.log
The proposed fix implements a health check that uses pg_isready to establish that postgres db is indeed ready, and for the django container to wait for db container to be healthy before kicking off migrations.