Healthchecks to ensure django container kicks off only after db container is healthy.#23
Healthchecks to ensure django container kicks off only after db container is healthy.#23radhaksri wants to merge 2 commits intoopenkilt:masterfrom
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.
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.
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.
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.
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.