Перенести решение lab3 как базу lab4

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-30 13:37:23 +03:00
co-authored by Claude Opus 5.5
parent ec540a1a72
commit e9ee60b0ba
31 changed files with 2856 additions and 0 deletions
+21
View File
@@ -0,0 +1,21 @@
#!/bin/sh
# Failover hook: останавливает ОДНУ API-реплику, обслужившую тест, и оставляет её остановленной.
# TARGET_INSTANCE_ID = X-Instance-Id = hostname контейнера = префикс его Docker ID.
# БД, LB и volumes не затрагиваются. Восстановление: scripts/start-api.sh.
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
. "$(dirname "$0")/lib.sh"
case "$TARGET_INSTANCE_ID" in
*[!0-9a-f]* | "") echo "unexpected instance id format" >&2; exit 2 ;;
esac
target=""
for id in $(service_ids api); do
case "$id" in "$TARGET_INSTANCE_ID"*) target="$id" ;; esac
done
if [ -z "$target" ]; then
echo "instance $TARGET_INSTANCE_ID is not a running api container of project $PROJECT" >&2
exit 3
fi
# docker stop = SIGTERM -> graceful drain (~3 s) -> выход; SIGKILL только после 15 s.
docker stop --time 15 "$target" >/dev/null
echo "stopped api container $(short "$target") at $(date -u +%H:%M:%S)"