15 lines
602 B
Bash
Executable File
15 lines
602 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
: "${TARGET_INSTANCE_ID:?test provides target API instance alias}"
|
|
case "$TARGET_INSTANCE_ID" in
|
|
*[!0-9a-f]*) echo "unexpected instance id format" >&2; exit 2 ;;
|
|
esac
|
|
cid=$(docker ps -q --filter "id=$TARGET_INSTANCE_ID" \
|
|
--filter "label=com.docker.compose.project=mtusi-lab4" \
|
|
--filter "label=com.docker.compose.service=api")
|
|
[ -n "$cid" ] || { echo "no running api replica matches" >&2; exit 3; }
|
|
[ "$(printf '%s\n' "$cid" | wc -l)" -eq 1 ] || { echo "ambiguous id" >&2; exit 3; }
|
|
docker stop -t 15 "$cid" >/dev/null
|
|
echo "stopped api container $cid"
|