Files

17 lines
520 B
Python

#!/usr/bin/env python3
import sys
import time
import urllib.request
url = sys.argv[1] if len(sys.argv) > 1 else 'http://localhost:8080/health/ready'
timeout = int(sys.argv[2]) if len(sys.argv) > 2 else 30
deadline = time.monotonic() + timeout
while time.monotonic() < deadline:
try:
with urllib.request.urlopen(url, timeout=2) as response:
if response.status == 200:
raise SystemExit(0)
except Exception:
time.sleep(0.5)
raise SystemExit('Readiness timeout: ' + url)