27 lines
986 B
Bash
Executable File
27 lines
986 B
Bash
Executable File
#!/bin/sh
|
|
# Failover hook for `make test-failover ACTION_SCRIPT=scripts/stop-one.sh`.
|
|
# Stops ONE API replica (selected by TARGET_INSTANCE_ID = api-1 or api-2) and
|
|
# leaves it stopped; the load balancer keeps serving via the remaining replica.
|
|
# Does not touch postgres, valkey, nginx or any volumes. Restore the replica
|
|
# explicitly after the test (docker compose start <service>).
|
|
set -eu
|
|
|
|
cd "$(dirname "$0")/.."
|
|
|
|
ENV_FILE="${COMPOSE_ENV_FILE:-.env}"
|
|
|
|
: "${TARGET_INSTANCE_ID:?test provides target API instance alias (api-1 or api-2)}"
|
|
|
|
case "$TARGET_INSTANCE_ID" in
|
|
api-1|api-2) ;;
|
|
*)
|
|
printf '%s\n' "stop-one: invalid TARGET_INSTANCE_ID='$TARGET_INSTANCE_ID' (expected api-1 or api-2)" >&2
|
|
exit 2
|
|
;;
|
|
esac
|
|
|
|
printf '%s\n' "stop-one: stopping API replica $TARGET_INSTANCE_ID (nginx keeps serving via the other replica)"
|
|
docker compose --env-file "$ENV_FILE" stop --timeout 10 "$TARGET_INSTANCE_ID"
|
|
|
|
printf '%s\n' "stop-one: $TARGET_INSTANCE_ID stopped"
|