From 0f3d82a5e6de7100f2870f15c84f9406f0cbce6b Mon Sep 17 00:00:00 2001 From: vabene1111 Date: Wed, 2 Mar 2022 12:22:12 +0100 Subject: [PATCH] fixing boot script --- boot.sh | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/boot.sh b/boot.sh index 313fbd42..4f8a41f3 100644 --- a/boot.sh +++ b/boot.sh @@ -28,22 +28,25 @@ fi echo "Waiting for database to be ready..." -attempt=0 -max_attempts=20 -while pg_isready --host=${POSTGRES_HOST} -q; status=$?; attempt=$((attempt+1)); [ $status -ne 0 ] && [ $attempt -le $max_attempts ]; do - sleep 5 -done +if [ "${DB_ENGINE}" != 'django.db.backends.sqlite3' ]; then + attempt=0 + max_attempts=20 + while pg_isready --host=${POSTGRES_HOST} -q; status=$?; attempt=$((attempt+1)); [ $status -ne 0 ] && [ $attempt -le $max_attempts ]; do + sleep 5 + done + + if [ $attempt -gt $max_attempts ]; then + echo -e "\nDatabase not reachable. Maximum attempts exceeded." + echo "Please check logs above - misconfiguration is very likely." + echo "Make sure the DB container is up and POSTGRES_HOST is set properly." + echo "Shutting down container." + exit 1 # exit with error to make the container stop + fi + + echo "Database is ready" -if [ $attempt -gt $max_attempts ]; then - echo -e "\nDatabase not reachable. Maximum attempts exceeded." - echo "Please check logs above - misconfiguration is very likely." - echo "Make sure the DB container is up and POSTGRES_HOST is set properly." - echo "Shutting down container." - exit 1 # exit with error to make the container stop fi -echo "Database is ready" - echo "Migrating database"