Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 2 additions & 6 deletions tools/docker-compose/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@ services:
context: $PWD
dockerfile: wisdom-service.Containerfile
depends_on:
redis:
condition: service_started
db:
condition: service_healthy
- redis
- db
restart: always
volumes:
- $PWD/ansible_wisdom:/var/www/ansible_wisdom
Expand Down Expand Up @@ -43,8 +41,6 @@ services:
- POSTGRES_DB=wisdom
- POSTGRES_USER=wisdom
restart: always
healthcheck:
test: pg_isready -U wisdom
networks:
- dbnet
# Disabled because this doesn't work properly on MacOS.
Expand Down
6 changes: 6 additions & 0 deletions tools/scripts/launch-wisdom.sh
Original file line number Diff line number Diff line change
@@ -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
Copy link
Contributor

@jameswnl jameswnl Feb 2, 2023

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)

Copy link
Contributor Author

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.

do
echo "Waiting until the database is ready..."
sleep 5
Copy link
Contributor

@gebhardtr gebhardtr Feb 2, 2023

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"?)

Copy link
Contributor Author

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.

done

/var/www/venv/bin/python ansible_wisdom/manage.py migrate --noinput

cd ansible_wisdom/
Expand Down