diff --git a/deploy/docker/fs/opt/appsmith/entrypoint.sh b/deploy/docker/fs/opt/appsmith/entrypoint.sh index 685c0b8fd0a..221be8379a5 100644 --- a/deploy/docker/fs/opt/appsmith/entrypoint.sh +++ b/deploy/docker/fs/opt/appsmith/entrypoint.sh @@ -467,8 +467,15 @@ create_appsmith_pg_db() { # Start the postgres , wait for it to be ready and create a appsmith db su postgres -c "env PATH='$PATH' pg_ctl -D $POSTGRES_DB_PATH -l $POSTGRES_DB_PATH/logfile start" echo "Waiting for Postgres to start" + local max_attempts=100 + local attempt=0 + until su postgres -c "env PATH='$PATH' pg_isready -d postgres"; do - tlog "Waiting for Postgres to be ready..." + if (( attempt >= max_attempts )); then + echo "Postgres failed to start within 100 seconds." + return 1 + fi + tlog "Waiting for Postgres to be ready... Attempt $((++attempt))/$max_attempts" sleep 1 done # Check if the appsmith DB is present