forked from mtusi2026/mtusi2026lab3
выполнение лабы на 5
This commit is contained in:
Executable
+32
@@ -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
|
||||
Reference in New Issue
Block a user