Add code to initializeDb.sh to wait for the mysql database

to be ready before trying to initialize it. This fixes
    a first time startup problem.
This commit is contained in:
Robert Adams
2019-11-25 18:35:54 -08:00
parent 475da0c646
commit bc711c52da
@@ -16,9 +16,6 @@ if [[ ! -z "$MYSQL_ROOT_PASSWORD" ]] ; then
rm -f "$SQLCMDS"
rm -f "$SQLOPTIONS"
# If the database is started at the same time, what for it to initialize
sleep 10
cat > "$SQLCMDS" <<EOFFFF
CREATE DATABASE opensim;
USE opensim;
@@ -33,6 +30,14 @@ password=$MYSQL_ROOT_PASSWORD
host=$MYSQL_DB_SOURCE
EOFFFF
# If the database is started at the same time, what for it to initialize
until mysql --defaults-extra-file=$SQLOPTIONS -e "show databases" ; do
echo "initializeDb.sh: Waiting on database to be ready"
sleep 2
done
echo "initializeDb.sh: Database is ready"
HASDB=$(mysql --defaults-extra-file=$SQLOPTIONS -e "show databases" | grep "^opensim$")
if [[ -z "$HASDB" ]] ; then