Compare commits

...

1 Commits

Author SHA1 Message Date
Alexander Whitestone
237aeaaca0 fix: closes #802
Some checks failed
CI / test (pull_request) Failing after 10s
CI / validate (pull_request) Failing after 16s
Review Approval Gate / verify-review (pull_request) Failing after 3s
2026-04-12 12:18:42 -04:00

View File

@@ -586,8 +586,8 @@ def alert_on_failure(report: HealthReport, dry_run: bool = False) -> None:
logger.info("Created alert issue #%d", result["number"])
def run_once(args: argparse.Namespace) -> bool:
"""Run one health check cycle. Returns True if healthy."""
def run_once(args: argparse.Namespace) -> tuple[bool, HealthReport]:
"""Run one health check cycle. Returns (healthy, report)."""
report = run_health_checks(
ws_host=args.ws_host,
ws_port=args.ws_port,
@@ -615,7 +615,20 @@ def run_once(args: argparse.Namespace) -> bool:
except Exception:
pass # never crash the watchdog over its own heartbeat
return report.overall_healthy
return report.overall_healthy, report
def _emit_json(report: HealthReport) -> None:
"""Print a HealthReport as JSON to stdout."""
print(json.dumps({
"healthy": report.overall_healthy,
"timestamp": report.timestamp,
"checks": [
{"name": c.name, "healthy": c.healthy,
"message": c.message, "details": c.details}
for c in report.checks
],
}, indent=2))
def main():
@@ -678,30 +691,18 @@ def main():
signal.signal(signal.SIGINT, _handle_sigterm)
while _running:
run_once(args)
_healthy, report = run_once(args)
if args.output_json:
_emit_json(report)
for _ in range(args.interval):
if not _running:
break
time.sleep(1)
else:
healthy = run_once(args)
healthy, report = run_once(args)
if args.output_json:
report = run_health_checks(
ws_host=args.ws_host,
ws_port=args.ws_port,
heartbeat_path=Path(args.heartbeat_path),
stale_threshold=args.stale_threshold,
)
print(json.dumps({
"healthy": report.overall_healthy,
"timestamp": report.timestamp,
"checks": [
{"name": c.name, "healthy": c.healthy,
"message": c.message, "details": c.details}
for c in report.checks
],
}, indent=2))
_emit_json(report)
sys.exit(0 if healthy else 1)