forked from mtusi2026/mtusi2026lab6
17 lines
988 B
Python
17 lines
988 B
Python
#!/usr/bin/env python3
|
|
"""Wait for the business endpoint and each telemetry backend, not only running processes."""
|
|
import subprocess,time,urllib.request
|
|
from pathlib import Path
|
|
root=Path(__file__).resolve().parents[1]
|
|
checks=['http://otel-collector:13133/','http://prometheus:9090/-/ready','http://loki:3100/ready','http://tempo:3200/ready','http://grafana:3000/api/health']
|
|
end=time.monotonic()+120
|
|
while time.monotonic()<end:
|
|
try:
|
|
with urllib.request.urlopen('http://127.0.0.1:18086/health/ready',timeout=2) as r:
|
|
if r.status!=200:raise RuntimeError()
|
|
for url in checks:
|
|
subprocess.run([str(root/'scripts/compose.sh'),'exec','-T','--index','1','api','wget','-q','-O','/dev/null',url],check=True,stdout=subprocess.DEVNULL,stderr=subprocess.DEVNULL,timeout=5)
|
|
print('PASS: business, Collector, Prometheus, Loki, Tempo and Grafana ready');break
|
|
except Exception:time.sleep(2)
|
|
else:raise SystemExit('FAIL: stand readiness timeout')
|