MCPcopy Create free account
hub / github.com/cxapython/catvm / get_services

Function get_services

selenium/deploy.py:101–115  ·  view source on GitHub ↗
(service_name)

Source from the content-addressed store, hash-verified

99 pass
100
101def get_services(service_name):
102 if 'HOST_IP' not in os.environ:
103 raise Exception('environment HOST_IP not found, which should be consul listened ip')
104 if not args.dns:
105 consul_url = 'http://{}:8500/v1/health/service/{}'.format(os.environ.get('HOST_IP'), service_name)
106 resp = requests.get(consul_url, timeout=30)
107 nodes = json.loads(resp.text)
108 if len(nodes) == 0:
109 raise Exception('service {} not found'.format(service_name))
110 services = []
111 for node in nodes:
112 services.append((node['Service']['Address'], node['Service']['Port']))
113 return services
114 services = [(os.environ.get('HOST_IP'), '5000')]
115 return services
116
117def main():
118 commit_id = get_commit_id()

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected