Files
mtusi2026lab7/scripts/stop-one.sh
T
Бахрам 1df2202403
Skeleton contracts / contracts (pull_request) Canceled after 0s
Complete lab 7 TLS and secret management
2026-12-01 22:44:28 +03:00

16 lines
477 B
Bash
Executable File

#!/bin/sh
set -eu
cd "$(dirname "$0")/.."
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
for service in api1 api2; do
cid=$(docker compose ps -q "$service")
[ -n "$cid" ] || continue
identity=$(docker inspect --format '{{range .Config.Env}}{{println .}}{{end}}' "$cid" | sed -n 's/^APP_INSTANCE_ID=//p')
if [ "$identity" = "$TARGET_INSTANCE_ID" ]; then
docker compose stop -t 2 "$service"
exit 0
fi
done
echo 'Target instance not found' >&2
exit 1