20 lines
631 B
Python
20 lines
631 B
Python
"""Wait for the public entrypoint after starting the Compose stack."""
|
|
import os
|
|
import time
|
|
import urllib.error
|
|
import urllib.request
|
|
|
|
base = os.getenv('BASE_URL', 'http://127.0.0.1:8084').rstrip('/')
|
|
deadline = time.monotonic() + 90
|
|
while True:
|
|
try:
|
|
with urllib.request.urlopen(base + '/health/ready', timeout=3) as response:
|
|
if response.status == 200:
|
|
print('READY:', base)
|
|
break
|
|
except (urllib.error.URLError, OSError):
|
|
pass
|
|
if time.monotonic() >= deadline:
|
|
raise SystemExit('Public API did not become ready within 90 seconds')
|
|
time.sleep(.5)
|