forked from mtusi2026/mtusi2026lab3
FastAPI + PostgreSQL как единый источник истины: пользователи, Basic/Bearer-сессии, чаты, сообщения. Сессии и идемпотентные ключи хранятся в БД, поэтому реплики взаимозаменяемы. Общая идемпотентность POST сообщения по Idempotency-Key, включая конкурентный повтор через разные реплики. compose.yaml: postgres, one-shot migrate, api1, api2 и nginx как единственная публичная точка входа. Добавлены scripts/stop-one.sh и scripts/restart.sh, student-tests, evidence и заполненный REPORT.md.
24 lines
806 B
Bash
Executable File
24 lines
806 B
Bash
Executable File
#!/bin/sh
|
|
# Stop exactly one API replica identified by the X-Instance-Id alias supplied
|
|
# by the failover test. The replica is intentionally left stopped; restore it
|
|
# explicitly with: docker compose start api1 (or api2).
|
|
set -eu
|
|
|
|
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
|
|
|
case "$TARGET_INSTANCE_ID" in
|
|
api-1) service=api1 ;;
|
|
api-2) service=api2 ;;
|
|
*)
|
|
printf 'unknown API instance alias: %s\n' "$TARGET_INSTANCE_ID" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
|
|
cd "$ROOT"
|
|
|
|
# -t 2 keeps the hook well inside the test's 10 second budget. `stop` keeps the
|
|
# container (and volumes) in place and the container is not restarted by policy.
|
|
exec docker compose --env-file .env -f compose.yaml stop --timeout 2 "$service"
|