Lab3: HAProxy, API replicas, idempotency for grade 4

This commit is contained in:
2026-11-11 01:29:57 +03:00
parent 0ab3a341aa
commit 9f25648c1b
37 changed files with 2083 additions and 26 deletions
+18
View File
@@ -0,0 +1,18 @@
#!/bin/sh
set -eu
# Stop ONE API replica matching TARGET_INSTANCE_ID (= X-Instance-Id = container hostname).
# Leave it stopped; do not touch DB/LB/volumes. Return quickly.
cd "$(dirname "$0")/.."
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID required}"
for id in $(docker compose --env-file .env ps -q api); do
[ -n "$id" ] || continue
host=$(docker inspect -f '{{.Config.Hostname}}' "$id")
if [ "$host" = "$TARGET_INSTANCE_ID" ]; then
docker stop "$id" >/dev/null
exit 0
fi
done
printf '%s\n' "API replica not found for TARGET_INSTANCE_ID" >&2
exit 1