From 749754b8739f6598f98aa36af4eefeba52b9d1c7 Mon Sep 17 00:00:00 2001 From: Matheus Fernandes Date: Mon, 13 Nov 2017 15:20:14 -0200 Subject: [PATCH] Add scripto to check db health Signed-off-by: Matheus Fernandes --- start-colab.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/start-colab.sh b/start-colab.sh index 0c6cbd7d..5c786bae 100755 --- a/start-colab.sh +++ b/start-colab.sh @@ -31,7 +31,16 @@ fi crond -PGPASSWORD=$DATABASE_PASSWORD psql -U $DATABASE_USER -w -h $DATABASE_HOST -c "CREATE DATABASE ${DATABASE_NAME} OWNER root" +while true; do + PG_STATUS=`PGPASSWORD=$DATABASE_PASSWORD psql -U $DATABASE_USER -w -h $DATABASE_HOST -c '\l \q' | grep postgres | wc -l` + if ! [ "$PG_STATUS" -eq "0" ]; then + break + fi + echo "Waiting Database Setup" + sleep 10 +done + +PGPASSWORD=$DATABASE_PASSWORD psql -U $DATABASE_USER -w -h $DATABASE_HOST -c "CREATE DATABASE ${DATABASE_NAME} OWNER ${DATABASE_USER}" colab-admin migrate colab-admin initdb