commit faebc047a0812dbefe07879821cf07d6df852d97 parent 717f33455234e69d47d49e9d149ef97ca74d8614 Author: Florian Dold <florian@dold.me> Date: Mon, 23 Jun 2025 16:35:24 +0200 wait for postgres to become ready Diffstat:
| M | scripts/demo/setup-sandcastle.sh | | | 18 | ++++++++++++++++++ |
1 file changed, 18 insertions(+), 0 deletions(-)
diff --git a/scripts/demo/setup-sandcastle.sh b/scripts/demo/setup-sandcastle.sh @@ -413,6 +413,24 @@ EOF systemctl start postgresql.service +while true; do + pg_isready; ret=$? + case "$ret" in + 0) + echo "Postgres is ready" >&2 + break + ;; + 1|2) + echo "pg_isready returned status $ret, waiting" >&2 + sleep 1 + ;; + 3) + echo "pg_isready returned status $ret, giving up" >&2 + exit 3 + ;; + esac +done + # Set up databases. # Do that *before* we potentially do a restore-from-backup.