Add commands to wait for the database to set up 55/38255/1
authorasteroide <thomas.duval@orange.com>
Thu, 27 Jul 2017 07:32:00 +0000 (09:32 +0200)
committerasteroide <thomas.duval@orange.com>
Thu, 27 Jul 2017 07:32:00 +0000 (09:32 +0200)
Change-Id: Ifa6453f4399b203611745820f4ea4ad8afcf49c8

moonv4/templates/moon_keystone/run.sh

index ea9b798..2a61901 100644 (file)
@@ -18,6 +18,13 @@ max_age = 3600
 allow_methods = POST,GET,DELETE
 EOF
 
+until echo status | mysql -h${DB_HOST} -u${DB_USER_ROOT} -p${DB_PASSWORD_ROOT}; do
+  >&2 echo "MySQL is unavailable - sleeping"
+  sleep 1
+done
+
+>&2 echo "Mysql is up - executing command"
+
 mysql -h $DB_HOST -u$DB_USER_ROOT -p$DB_PASSWORD_ROOT <<EOF
 CREATE DATABASE $DB_DATABASE DEFAULT CHARACTER SET utf8 DEFAULT COLLATE utf8_general_ci;
 GRANT ALL ON $DB_DATABASE.* TO '$DB_USER'@'%' IDENTIFIED BY '$DB_PASSWORD';