#!/usr/bin/env bash set -euo pipefail : "${AIGW_READY_URL:?AIGW_READY_URL is required}" : "${AIGW_REDIS_CONTAINER:?AIGW_REDIS_CONTAINER is required}" cleanup() { docker start "$AIGW_REDIS_CONTAINER" >/dev/null 2>&1 || true; } trap cleanup EXIT docker stop "$AIGW_REDIS_CONTAINER" >/dev/null for _ in $(seq 1 20); do body="$(curl --silent --show-error --fail "$AIGW_READY_URL" || true)" if printf '%s' "$body" | grep -q '"redis"' && printf '%s' "$body" | grep -q '"required":false'; then printf 'redis degradation confirmed; gateway remained ready\n' exit 0 fi sleep 1 done printf 'gateway did not report recoverable Redis degradation\n' >&2 exit 1