Реализация ЛР 3 на оценку 3: HAProxy, 2 реплики API, идемпотентность, evidence

This commit is contained in:
2026-11-10 01:26:52 +03:00
parent 0ab3a341aa
commit de55dd1d8a
29 changed files with 2032 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
#!/bin/sh
# Останавливает ОДНУ API-реплику по TARGET_INSTANCE_ID (= hostname контейнера = короткий ID)
# Реплика остаётся остановленной. БД, LB и volumes не затрагиваются
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
case "$TARGET_INSTANCE_ID" in
""|*[!A-Za-z0-9_.-]*) echo "bad instance id" >&2; exit 2 ;;
esac
cd "$(dirname "$0")/.."
CID=$(docker ps --filter "label=com.docker.compose.service=api" \
--filter "id=$TARGET_INSTANCE_ID" --format '{{.ID}}')
[ -n "$CID" ] || { echo "no running api container for this instance" >&2; exit 1; }
docker stop -t 2 "$CID" >/dev/null
echo "stopped api container $CID" >&2