forked from mtusi2026/mtusi2026lab3
Добавить scripts отказа и трека масштабирования
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
|
||||
# X-Instance-Id is the container hostname (the Docker short ID). Resolve it to
|
||||
# exactly one scaled Compose container and stop only that process.
|
||||
for id in $(docker compose --env-file .env ps -q api); do
|
||||
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$id")
|
||||
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
|
||||
docker stop --time 3 "$id" >/dev/null
|
||||
exit 0
|
||||
fi
|
||||
done
|
||||
echo "No running api container matches TARGET_INSTANCE_ID" >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user