| 99 | pass |
| 100 | |
| 101 | def 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 | |
| 117 | def main(): |
| 118 | commit_id = get_commit_id() |