forked from mtusi2026/mtusi2026lab3
25 lines
453 B
Bash
Executable File
25 lines
453 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
|
|
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
found=""
|
|
ids=$(docker compose --env-file .env ps -q api)
|
|
for id in $ids; do
|
|
host=$(docker inspect -f '{{.Config.Hostname}}' "$id")
|
|
if [ "$host" = "$TARGET_INSTANCE_ID" ]; then
|
|
found=$id
|
|
break
|
|
fi
|
|
done
|
|
|
|
if [ -z "$found" ]; then
|
|
echo "api replica not found" >&2
|
|
exit 1
|
|
fi
|
|
|
|
docker stop -t 8 "$found" >/dev/null
|
|
exit 0
|