forked from mtusi2026/mtusi2026lab4
completed lab4
This commit is contained in:
Executable
+16
@@ -0,0 +1,16 @@
|
||||
#!/bin/sh
|
||||
set -eu
|
||||
cd "$(dirname "$0")/.."
|
||||
: "${TARGET_INSTANCE_ID:?Set TARGET_INSTANCE_ID from a real API response}"
|
||||
for id in $(docker compose ps -q api); do
|
||||
host=$(docker inspect -f '{{.Config.Hostname}}' "$id")
|
||||
case "$TARGET_INSTANCE_ID" in
|
||||
"$host"-*)
|
||||
printf 'Stopping API container %s (hostname %s)\n' "$id" "$host"
|
||||
docker stop --time 5 "$id"
|
||||
docker inspect -f '{{.Id}} {{.State.Status}}' "$id"
|
||||
exit 0;;
|
||||
esac
|
||||
done
|
||||
printf 'No running API matches target\n' >&2
|
||||
exit 1
|
||||
Reference in New Issue
Block a user