api.py 912 B

123456789101112131415161718192021222324252627282930313233343536
  1. # Copyright 2016 Cloudbase Solutions Srl
  2. # All Rights Reserved.
  3. import sys
  4. from oslo_concurrency import processutils
  5. from oslo_config import cfg
  6. from coriolis import service
  7. from coriolis import utils
  8. api_opts = [
  9. cfg.IntOpt(
  10. 'worker_count', min=1, default=processutils.get_worker_count(),
  11. help='Number of processes in which the service will be running')]
  12. CONF = cfg.CONF
  13. CONF.register_opts(api_opts, 'api')
  14. def main():
  15. worker_count, args = service.get_worker_count_from_args(sys.argv)
  16. CONF(args[1:], project='coriolis', version="1.0.0")
  17. if not worker_count:
  18. worker_count = CONF.api.worker_count
  19. utils.setup_logging()
  20. server = service.WSGIService(
  21. 'coriolis-api', worker_count=worker_count)
  22. launcher = service.service.launch(
  23. CONF, server, workers=server.get_workers_count())
  24. launcher.wait()
  25. if __name__ == "__main__":
  26. main()