ЛР 3 — БПИ2302 — Щербацевич — на 5

This commit is contained in:
2026-11-11 23:55:42 +03:00
parent 0ab3a341aa
commit 7aa4ea541b
76 changed files with 4627 additions and 34 deletions
+27
View File
@@ -0,0 +1,27 @@
#!/bin/sh
set -eu
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
cd "$ROOT"
found=""
for id in $(docker compose ps -aq -- api); do
hostname=$(docker inspect -f '{{.Config.Hostname}}' "$id")
name=$(docker inspect -f '{{.Name}}' "$id")
name=${name#/}
cid=$(docker inspect -f '{{.Id}}' "$id")
short=$(printf '%s' "$cid" | cut -c1-12)
if [ "$TARGET_INSTANCE_ID" = "$hostname" ] \
|| [ "$TARGET_INSTANCE_ID" = "$name" ] \
|| [ "$TARGET_INSTANCE_ID" = "$id" ] \
|| [ "$TARGET_INSTANCE_ID" = "$cid" ] \
|| [ "$TARGET_INSTANCE_ID" = "$short" ]; then
found=$id
break
fi
done
if [ -z "$found" ]; then
printf '%s\n' "no API replica matches TARGET_INSTANCE_ID" >&2
exit 1
fi
docker stop -t 5 "$found" >/dev/null
exit 0