-
Notifications
You must be signed in to change notification settings - Fork 11
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
Portable database health check #70
Conversation
to ensure that the Django migrations do not run until the database is fully up. The previous solution, to use the long form of `depends_on:` in our compose.yaml file, isn't supported by podman-compose: containers/podman-compose#453
until echo -e 'import sys\nfrom django.db import connection\ntry:\n connection.ensure_connection()\nexcept Exception:\n sys.exit(1)\n' | /var/www/venv/bin/python ansible_wisdom/manage.py shell | ||
do | ||
echo "Waiting until the database is ready..." | ||
sleep 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.
Does it make sense to factor this sleep
out of the loop and add it as a criterion in the probe? ("keep running launch_wisdom
until it succeeds"?)
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.
Both ways seem equivalent to me.
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.
This works for me.
tools/scripts/launch-wisdom.sh
Outdated
@@ -1,4 +1,10 @@ | |||
#!/bin/bash | |||
until echo -e 'import sys\nfrom django.db import connection\ntry:\n connection.ensure_connection()\nexcept Exception:\n sys.exit(1)\n' | /var/www/venv/bin/python ansible_wisdom/manage.py shell |
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.
How about using this format which makes python code easier on the eyes? https://gist.github.com/jameswnl/b6e6038aafef2dc3ae67e59b20180599
(This is from automation-analytics which is in GitLab. cleaned and dropped there for easier access)
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.
Yeah, I think that's a good idea. Updated.
to more readably construct the Python script to be run.
to ensure that the Django migrations do not run until the database is fully up.
The previous solution, to use the long form of
depends_on:
in our compose.yaml file, isn't supported by podman-compose: containers/podman-compose#453