forked from mtusi2026/mtusi2026lab3
scripts/stop-one.sh maps TARGET_INSTANCE_ID to the api container whose hostname matches, stops only it with docker stop -t 6 and leaves it stopped; an unknown id exits 3 and touches nothing. scripts/restart.sh replaces the lab 2 hook: it stops lb and the replicas, restarts PostgreSQL and Valkey with their volumes and brings the stand back with up --wait, which also reruns the idempotent migrate job. scripts/restore.sh starts stopped replicas without recreating them and scripts/lb-wait.sh waits until the balancer statistics show every replica UP again, so the next failover run sees two replicas. scripts/probe.py check (stdlib, Python 3.9 syntax) counts X-Instance-Id over 40 calls with one token and races 8 posts with one key through the balancer. make restore and make lb-check run them, ruff covers the probe, and the CI acceptance job runs the failover test and the probe. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
13 lines
454 B
Bash
Executable File
13 lines
454 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
defined=$(docker compose config --services)
|
|
stores=""
|
|
for service in ${STATE_SERVICES:-postgres valkey}; do
|
|
if printf '%s\n' "$defined" | grep -qx "$service"; then stores="$stores $service"; fi
|
|
done
|
|
[ -n "$stores" ] || { echo "no state services found" >&2; exit 3; }
|
|
docker compose stop lb "${API_SERVICE:-api}"
|
|
docker compose restart $stores
|
|
docker compose up -d --wait --wait-timeout "${WAIT_TIMEOUT:-75}"
|