Make all services use the same launching strategy

This commit is contained in:
Vishvananda Ishaya
2011-08-17 16:25:53 -07:00
parent 192dd49f5e
commit 387467e26c

View File

@@ -19,12 +19,15 @@
"""Starter script for Nova API. """Starter script for Nova API.
Starts both the EC2 and OpenStack APIs in separate processes. Starts both the EC2 and OpenStack APIs in separate greenthreads.
""" """
import eventlet
eventlet.monkey_patch()
import gettext
import os import os
import signal
import sys import sys
@@ -33,32 +36,19 @@ possible_topdir = os.path.normpath(os.path.join(os.path.abspath(
if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")): if os.path.exists(os.path.join(possible_topdir, "nova", "__init__.py")):
sys.path.insert(0, possible_topdir) sys.path.insert(0, possible_topdir)
import nova.service gettext.install('nova', unicode=1)
import nova.utils
from nova import flags from nova import flags
from nova import log as logging
from nova import service
FLAGS = flags.FLAGS from nova import utils
def main():
"""Launch EC2 and OSAPI services."""
nova.utils.Bootstrapper.bootstrap_binary(sys.argv)
launcher = nova.service.Launcher()
for api in FLAGS.enabled_apis:
service = nova.service.WSGIService(api)
launcher.launch_service(service)
signal.signal(signal.SIGTERM, lambda *_: launcher.stop())
try:
launcher.wait()
except KeyboardInterrupt:
launcher.stop()
if __name__ == '__main__': if __name__ == '__main__':
sys.exit(main()) utils.default_flagfile()
flags.FLAGS(sys.argv)
logging.setup()
services = []
for api in flags.FLAGS.enabled_apis:
services.append(service.WSGIService(api))
service.serve(*services)
service.wait()