diff --git a/scripts/check-explorer-health.sh b/scripts/check-explorer-health.sh index 9c7fe2f..dfe40d9 100755 --- a/scripts/check-explorer-health.sh +++ b/scripts/check-explorer-health.sh @@ -7,6 +7,7 @@ BASE_URL="${1:-https://explorer.d-bis.org}" python3 - "$BASE_URL" <<'PY' import re import sys +import time import requests @@ -158,15 +159,22 @@ try: if resp.status_code >= 400: failed = True else: - lines = [] + saw_event = False + saw_data = False + deadline = time.time() + 25 for raw in resp.iter_lines(decode_unicode=True): if raw: - lines.append(raw) - if len(lines) >= 2: + if raw.startswith("event:"): + saw_event = True + if raw.startswith("data:"): + saw_data = True + if saw_event and saw_data: break - if not any(line.startswith("event:") for line in lines): + if time.time() > deadline: + break + if not saw_event: mark_failure(" mission-control stream did not emit an event line") - if not any(line.startswith("data:") for line in lines): + if not saw_data: mark_failure(" mission-control stream did not emit a data line") except Exception as exc: mark_failure(f"ERR /explorer-api/v1/mission-control/stream [{exc}]")