Files
mtusi2026lab7/scripts/wait_ready.py
T
lxstatmose 2c2734df60
Skeleton contracts / contracts (pull_request) Canceled after 0s
Лабораторная 7: TLS, mTLS и OpenBao
2026-11-28 01:28:30 +03:00

16 lines
713 B
Python

#!/usr/bin/env python3
"""Bounded verified-HTTPS readiness wait."""
import ssl,time,urllib.request
context=ssl.create_default_context(cafile='secrets/ca/ca.crt')
pending={'api':'https://localhost:8443/health/ready','grafana':'https://localhost:17400/api/health'}
deadline=time.monotonic()+120
while pending and time.monotonic()<deadline:
for name,url in list(pending.items()):
try:
with urllib.request.urlopen(url,context=context,timeout=2) as response:
if response.status==200:del pending[name]
except OSError:pass
if pending:time.sleep(1)
if pending:raise SystemExit('Readiness timeout: '+','.join(pending))
print('PASS verified HTTPS API and Grafana ready')