16 lines
600 B
Bash
Executable File
16 lines
600 B
Bash
Executable File
#!/bin/sh
|
|
set -eu
|
|
cd "$(dirname "$0")/.."
|
|
: "${TARGET_INSTANCE_ID:?TARGET_INSTANCE_ID is required}"
|
|
found=''
|
|
for id in $(scripts/compose.sh ps -q api); do
|
|
actual=$(docker exec "$id" python -c 'import urllib.request; r=urllib.request.urlopen("http://127.0.0.1:8080/health/live",timeout=2); print(r.headers["X-Instance-Id"])')
|
|
if [ "$actual" = "$TARGET_INSTANCE_ID" ]; then
|
|
found="$id"
|
|
break
|
|
fi
|
|
done
|
|
[ -n "$found" ] || { echo 'No matching running API process' >&2; exit 1; }
|
|
printf 'Stopping API container %s instance %s\n' "$found" "$TARGET_INSTANCE_ID"
|
|
docker stop --timeout 6 "$found"
|