forked from mtusi2026/mtusi2026lab4
ЛР 4 - БПИ2302 - Щербацевич - на 4
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
ROOT=$(CDPATH= cd -- "$(dirname "$0")/.." && pwd)
|
||||
cd "$ROOT"
|
||||
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
|
||||
|
||||
found=
|
||||
for id in $(docker compose --env-file .env ps -q api); do
|
||||
hostname=$(docker inspect -f '{{.Config.Hostname}}' "$id")
|
||||
instance=$(docker inspect -f '{{range .Config.Env}}{{println .}}{{end}}' "$id" | awk -F= '$1=="INSTANCE_ID"{print $2}')
|
||||
if [ "$hostname" = "$TARGET_INSTANCE_ID" ] || [ "${instance:-}" = "$TARGET_INSTANCE_ID" ] || [ "$id" = "$TARGET_INSTANCE_ID" ]; then
|
||||
docker stop "$id" >/dev/null
|
||||
found=1
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
if [ -z "$found" ]; then
|
||||
echo "no api replica matched TARGET_INSTANCE_ID" >&2
|
||||
exit 1
|
||||
fi
|
||||
Reference in New Issue
Block a user