#!/bin/sh # Restart hook for `make test-persistence ACTION_SCRIPT=scripts/restart.sh`. # Restarts the API and ALL state stores (PostgreSQL, Valkey) of compose.yaml. # Volumes, schema and data are preserved: no `down -v`, no FLUSH, no re-seed. # Output is suppressed by the test; run it by hand to see the steps. set -eu cd "$(dirname "$0")/.." # 1. API first: no request is served while the stores restart underneath it. docker compose stop api # 2. Stores: clean shutdown (PostgreSQL checkpoint, Valkey AOF fsync), then start again. docker compose restart postgres valkey # 3. API again; it waits for healthy stores via depends_on and reconnects its pool. docker compose start api echo "restart.sh: api, postgres and valkey restarted with volumes preserved"