forked from mtusi2026/mtusi2026lab5
17 lines
441 B
Python
17 lines
441 B
Python
import os
|
|
import time
|
|
import urllib.request
|
|
|
|
base = os.environ.get('BASE_URL', 'http://127.0.0.1:18087')
|
|
for attempt in range(120):
|
|
try:
|
|
with urllib.request.urlopen(base + '/health/ready', timeout=2) as response:
|
|
if response.status == 200:
|
|
print('Ready through load balancer.')
|
|
break
|
|
except OSError:
|
|
pass
|
|
time.sleep(0.5)
|
|
else:
|
|
raise SystemExit('Readiness timeout')
|