1f420b82f6
Many processes should not start until the pushgateway has come online and is ready to serve traffic. This change adds a simple loop in the run command in order to spinlock until this condition as been met.
22 lines
580 B
Python
22 lines
580 B
Python
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()
|