23 lines
853 B
Bash
Executable File
23 lines
853 B
Bash
Executable File
#!/bin/sh
|
|
# Stops the ONE API replica named by TARGET_INSTANCE_ID and leaves it stopped (no DB/LB/volume changes).
|
|
# The replica's X-Instance-Id is its container hostname, i.e. the short container id.
|
|
# Restore afterwards with: docker compose start api
|
|
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" >&2; exit 2 ;;
|
|
esac
|
|
|
|
# Only containers of the api service are candidates, so a wrong id can never stop the database or the balancer.
|
|
container=$(docker compose ps -q api | grep "^$TARGET_INSTANCE_ID" || true)
|
|
|
|
if [ -z "$container" ] || [ "$(printf '%s\n' "$container" | wc -l)" -ne 1 ]; then
|
|
echo "no single api replica matches $TARGET_INSTANCE_ID" >&2
|
|
exit 1
|
|
fi
|
|
|
|
docker stop --time 9 "$container" >/dev/null
|