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