Добавить scripts отказа и трека масштабирования

This commit is contained in:
2026-11-06 19:12:34 +03:00
parent 77dae0ec87
commit 41edfbc66b
5 changed files with 391 additions and 0 deletions
+14
View File
@@ -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