Fix bugs around passing master
Was not passing properly and getting stuck sometimes, so modify the checking and route creation a bit to prevent it. Seems to work.
This commit is contained in:
parent
8202d7e64b
commit
0a94fac407
|
@ -41,6 +41,7 @@ class MetadataAPIInstance(object):
|
||||||
self.logger = logger
|
self.logger = logger
|
||||||
self.thread = None
|
self.thread = None
|
||||||
self.md_http_server = None
|
self.md_http_server = None
|
||||||
|
self.add_routes()
|
||||||
|
|
||||||
# Add flask routes inside our instance
|
# Add flask routes inside our instance
|
||||||
def add_routes(self):
|
def add_routes(self):
|
||||||
|
@ -86,7 +87,6 @@ class MetadataAPIInstance(object):
|
||||||
|
|
||||||
def launch_wsgi(self):
|
def launch_wsgi(self):
|
||||||
try:
|
try:
|
||||||
self.add_routes()
|
|
||||||
self.md_http_server = gevent.pywsgi.WSGIServer(
|
self.md_http_server = gevent.pywsgi.WSGIServer(
|
||||||
('169.254.169.254', 80),
|
('169.254.169.254', 80),
|
||||||
self.mdapi,
|
self.mdapi,
|
||||||
|
@ -106,14 +106,17 @@ class MetadataAPIInstance(object):
|
||||||
self.logger.out('Successfully started Metadata API thread', state='o')
|
self.logger.out('Successfully started Metadata API thread', state='o')
|
||||||
|
|
||||||
def stop(self):
|
def stop(self):
|
||||||
|
if not self.md_http_server:
|
||||||
|
return
|
||||||
|
|
||||||
self.logger.out('Stopping Metadata API at 169.254.169.254:80', state='i')
|
self.logger.out('Stopping Metadata API at 169.254.169.254:80', state='i')
|
||||||
if self.thread and self.md_http_server:
|
try:
|
||||||
try:
|
self.md_http_server.stop()
|
||||||
self.md_http_server.stop()
|
self.md_http_server.close()
|
||||||
self.md_http_server.close()
|
self.md_http_server = None
|
||||||
self.logger.out('Successfully stopped Metadata API', state='o')
|
self.logger.out('Successfully stopped Metadata API', state='o')
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.out('Error stopping Metadata API: {}'.format(e), state='e')
|
self.logger.out('Error stopping Metadata API: {}'.format(e), state='e')
|
||||||
|
|
||||||
# Helper functions
|
# Helper functions
|
||||||
def open_database(self):
|
def open_database(self):
|
||||||
|
|
Loading…
Reference in New Issue