Support service-like wait behaviour for API service

This commit is contained in:
Justin Santa Barbara
2011-02-22 17:58:01 -08:00
parent bdbdb94760
commit 774a42b921
2 changed files with 8 additions and 3 deletions

View File

@@ -49,4 +49,5 @@ if __name__ == '__main__':
if not conf:
LOG.error(_("No paste configuration found for: %s"), 'nova-api.conf')
else:
apiservice.serve(conf)
service = apiservice.serve(conf)
service.wait()

View File

@@ -60,7 +60,7 @@ def _run_app(paste_config_file):
server = wsgi.Server()
for app in apps:
server.start(*app)
server.wait()
return server
class ApiService(object):
@@ -68,9 +68,13 @@ class ApiService(object):
def __init__(self, conf):
self.conf = conf
self.wsgi_app = None
def start(self):
_run_app(self.conf)
self.wsgi_app = _run_app(self.conf)
def wait(self):
self.wsgi_app.wait()
@staticmethod
def create():