2
0

api.py 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  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 oslo_reports import guru_meditation_report as gmr
  7. from oslo_reports import opts as gmr_opts
  8. from coriolis import service
  9. from coriolis import utils
  10. api_opts = [
  11. cfg.IntOpt(
  12. 'worker_count', min=1, default=processutils.get_worker_count(),
  13. help='Number of processes in which the service will be running')]
  14. CONF = cfg.CONF
  15. CONF.register_opts(api_opts, 'api')
  16. def main():
  17. worker_count, args = service.get_worker_count_from_args(sys.argv)
  18. CONF(args[1:], project='coriolis', version="1.0.0")
  19. if not worker_count:
  20. worker_count = CONF.api.worker_count
  21. utils.setup_logging()
  22. gmr_opts.set_defaults(CONF)
  23. gmr.TextGuruMeditation.setup_autorun(version="1.0.0", conf=CONF)
  24. server = service.WSGIService(
  25. 'coriolis-api', worker_count=worker_count)
  26. launcher = service.service.launch(
  27. CONF, server, workers=server.get_workers_count())
  28. launcher.wait()
  29. if __name__ == "__main__":
  30. main()