41 lines
1.0 KiB
Bash
Executable File
41 lines
1.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
|
|
set -euo pipefail
|
|
|
|
echo "Stopping application and stores..."
|
|
docker compose down
|
|
|
|
echo "Starting application and stores..."
|
|
docker compose up -d
|
|
|
|
echo "Waiting for services to become healthy..."
|
|
|
|
for attempt in $(seq 1 60); do
|
|
postgres_status=$(
|
|
docker compose ps postgres --format json \
|
|
| python -c 'import sys, json; data=json.load(sys.stdin); print(data.get("Health", ""))'
|
|
)
|
|
|
|
redis_status=$(
|
|
docker compose ps redis --format json \
|
|
| python -c 'import sys, json; data=json.load(sys.stdin); print(data.get("Health", ""))'
|
|
)
|
|
|
|
api_status=$(
|
|
docker compose ps api --format json \
|
|
| python -c 'import sys, json; data=json.load(sys.stdin); print(data.get("Health", ""))'
|
|
)
|
|
|
|
if [[ "$postgres_status" == "healthy" \
|
|
&& "$redis_status" == "healthy" \
|
|
&& "$api_status" == "healthy" ]]; then
|
|
echo "All services are healthy."
|
|
exit 0
|
|
fi
|
|
|
|
sleep 1
|
|
done
|
|
|
|
echo "Services did not become healthy in time." >&2
|
|
docker compose ps
|
|
exit 1 |