laba 5 mark 4

This commit is contained in:
2026-11-10 14:47:33 +03:00
parent 276dbdad8a
commit 5ca6b6f7ad
75 changed files with 7466 additions and 36 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)"