add status route
This commit is contained in:
parent
03368f602f
commit
0a25acf806
2 changed files with 12 additions and 2 deletions
nginx_site_discovery
|
@ -68,8 +68,8 @@ def extract_site(config_file):
|
|||
server['listens'].append(parse_listen(words))
|
||||
elif words and 'server_name' == words[0]:
|
||||
server['names'] = parse_server_name(words)
|
||||
if healthcheck_url := opt.get('healthcheck_url'):
|
||||
server['healthcheck_url'] = healthcheck_url
|
||||
if 'healthcheck_url' in opt:
|
||||
server['healthcheck_url'] = opt['healthcheck_url']
|
||||
|
||||
servers.append(server)
|
||||
return servers
|
||||
|
|
|
@ -29,17 +29,27 @@ def service_discovery(request):
|
|||
return {"status": "Created"}
|
||||
|
||||
|
||||
def status(request):
|
||||
return {'status': 'ok'}
|
||||
|
||||
|
||||
class ServerController(threading.Thread):
|
||||
def __init__(self, ip, port, outdir):
|
||||
super().__init__()
|
||||
self.server_addr = (ip, port)
|
||||
with Configurator(settings={'outdir': outdir}) as config:
|
||||
config.add_route('service_discovery', '/{service}/{key}')
|
||||
config.add_route('status', '/status')
|
||||
config.add_view(
|
||||
service_discovery,
|
||||
route_name='service_discovery',
|
||||
request_method='POST',
|
||||
renderer='json')
|
||||
config.add_view(
|
||||
status,
|
||||
route_name='status',
|
||||
request_method='GET',
|
||||
renderer='json')
|
||||
app = config.make_wsgi_app()
|
||||
|
||||
self.httpd = make_server(ip, port, app)
|
||||
|
|
Loading…
Reference in a new issue