Реализация на 5

This commit is contained in:
Grbisba
2026-11-17 13:08:13 +03:00
parent 470d9d6f1e
commit 60f48c0337
229 changed files with 74928 additions and 47 deletions
+19
View File
@@ -0,0 +1,19 @@
#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
: "${TARGET_INSTANCE_ID:?missing target alias}"
for id in $(./scripts/compose.sh ps -q api); do
current=$(docker exec "$id" wget -T 2 -qO- http://127.0.0.1:8080/internal/metrics | python3 -c 'import json,sys; print(json.load(sys.stdin)["instance_id"])')
if [ "$current" = "$TARGET_INSTANCE_ID" ]; then
docker stop --time 8 "$id" >/dev/null
python3 - "$id" "$TARGET_INSTANCE_ID" <<'PYLOG'
import json,sys,time
from pathlib import Path
with Path('evidence/failover-action.jsonl').open('a') as f:
f.write(json.dumps({'at':time.time(),'container':sys.argv[1],'instance_id':sys.argv[2],'action':'docker stop','project':'mtusi2026lab6'})+'\n')
PYLOG
exit 0
fi
done
printf '%s\n' 'Target does not match a running lab6 API process' >&2
exit 1