This repository has been archived on 2020-03-24. You can view files and clone it, but cannot push or open issues or pull requests.
quay/util/wait_for_endpoints.py

23 lines
580 B
Python
Raw Normal View History

from argparse import ArgumentParser
from contextlib import closing
from time import sleep
import requests
def main():
parser = ArgumentParser(description="block until the given endpoints return 200")
parser.add_argument('endpoints', type=str, nargs='+', help='the endpoints to wait for')
for endpoint in parser.parse_args().endpoints:
listening = False
while not listening:
try:
listening = requests.get(endpoint).status_code == 200
except requests.exceptions.ConnectionError:
pass
sleep(1)
if __name__ == '__main__':
main()