выполнение лабы на 5

This commit is contained in:
kaktuz20000
2026-10-21 09:44:11 +03:00
commit 176b9de2de
92 changed files with 12727 additions and 0 deletions
+32
View File
@@ -0,0 +1,32 @@
#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
ROOT=$(CDPATH= cd -- "$(dirname -- "$0")/.." && pwd)
cd "$ROOT"
target_container=
for container in $(docker compose --env-file .env ps -q api); do
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container")
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
target_container=$container
break
fi
done
if [ -z "$target_container" ]; then
printf '%s\n' 'No running API container matches TARGET_INSTANCE_ID.' >&2
exit 1
fi
if [ -n "${FAILOVER_EVIDENCE_FILE:-}" ]; then
case "$FAILOVER_EVIDENCE_FILE" in
/*) evidence_file=$FAILOVER_EVIDENCE_FILE ;;
*) evidence_file="$ROOT/$FAILOVER_EVIDENCE_FILE" ;;
esac
printf '%s target_instance=%s container=%s\n' \
"$(date -u +%Y-%m-%dT%H:%M:%SZ)" "$TARGET_INSTANCE_ID" "$target_container" \
>> "$evidence_file"
fi
docker stop --time 2 "$target_container" >/dev/null