Fix SQL race condition

When running "wait-for-mysql.sh", the "echo 'show tables' | manage.py
dbshell" command is always considered a success, even if the database is
unreachable ($? == 0). So we replace this command by a global system
check.

This closes #3.
This commit is contained in:
Régis Behmo 2018-02-10 18:38:17 +01:00
parent 1fcae62d2f
commit 6361b9ad58
4 changed files with 13 additions and 13 deletions

View File

@ -11,8 +11,8 @@ build:
docker-compose build
migrate:
docker-compose run --rm lms bash -c "./wait-for-mysql.sh && ./manage.py lms --settings=production migrate"
docker-compose run --rm cms bash -c "./wait-for-mysql.sh && ./manage.py cms --settings=production migrate"
docker-compose run --rm lms bash -c "./wait-for-greenlight.sh && ./manage.py lms --settings=production migrate"
docker-compose run --rm cms bash -c "./wait-for-greenlight.sh && ./manage.py cms --settings=production migrate"
assets:
docker-compose run --rm lms paver update_assets lms --settings=production

View File

@ -47,7 +47,7 @@ COPY ./config/lms.auth.json /openedx/
COPY ./config/cms.auth.json /openedx/
# Copy convenient script
COPY ./wait-for-mysql.sh .
COPY ./wait-for-greenlight.sh .
############ End of code common to lms & cms

10
edxapp/wait-for-greenlight.sh Executable file
View File

@ -0,0 +1,10 @@
#!/bin/bash
echo "Checking system..."
until ./manage.py lms --settings=production check
do
printf "."
sleep 1
done
echo -e "\nSystem is ready \\o/"

View File

@ -1,10 +0,0 @@
#!/bin/bash
echo "Waiting for mysql database"
until echo "show tables;" | ./manage.py lms --settings=production dbshell
do
printf "."
sleep 1
done
echo -e "\nmysql database ready"