forked from mtusi2026/mtusi2026lab4
17 lines
458 B
Bash
Executable File
17 lines
458 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
|
|
cd "$(dirname "$0")/.."
|
|
|
|
for container_id in $(docker compose --env-file .env ps -q api); do
|
|
hostname=$(docker inspect --format '{{.Config.Hostname}}' "$container_id")
|
|
|
|
if [ "$hostname" = "$TARGET_INSTANCE_ID" ]; then
|
|
docker stop --timeout 5 "$container_id" >/dev/null
|
|
exit 0
|
|
fi
|
|
done
|
|
|
|
printf 'API replica %s not found\n' "$TARGET_INSTANCE_ID" >&2
|
|
exit 1 |