#!/bin/sh set -eu # Sequenced: Nginx resolves upstream hostnames only at its own startup, so it # must come back strictly after api1/api2 exist again on the network. cd "$(dirname "$0")/.." wait_healthy() { for svc in "$@"; do for _ in $(seq 1 60); do status=$(docker compose ps --format '{{.Health}}' "$svc" 2>/dev/null || true) [ "$status" = "healthy" ] && break sleep 1 done done } # Sequenced on purpose: API eagerly connects to Postgres/Redis/S3 at startup # and exits if they are unreachable, and Nginx resolves upstream hostnames # only at its own startup -- so each stage must be actually healthy, not just # "restarted", before the next one comes up. docker compose restart postgres redis seaweedfs wait_healthy postgres redis seaweedfs docker compose restart api1 api2 wait_healthy api1 api2 docker compose restart lb exit 0