From df827906858747a0d9d134ae8ed04cc3b901811c Mon Sep 17 00:00:00 2001 From: Abhijeet Date: Mon, 14 Oct 2024 11:43:18 +0530 Subject: [PATCH] chore: Add polling for embedded pg start to create appsmith DB --- deploy/docker/fs/opt/appsmith/entrypoint.sh | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) 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