Skip to content

Commit a4e922c

Browse files
committed
Ops: add helper script to gate checks on postgres container readiness
1 parent 6d95cb4 commit a4e922c

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

scripts/wait_for_healthy.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
cd "$(dirname "$0")/.."
5+
6+
for i in {1..30}; do
7+
status=$(docker compose ps --format json 2>/dev/null | tr -d '\n' || true)
8+
if echo "$status" | grep -q '"Service":"postgres"' && echo "$status" | grep -q '"State":"running"'; then
9+
echo "postgres container is running"
10+
exit 0
11+
fi
12+
sleep 1
13+
done
14+
15+
echo "timed out waiting for postgres container"
16+
exit 1

0 commit comments

Comments
 (0)