| OLD | NEW |
| 1 # Copyright 2014 The Chromium Authors. All rights reserved. | 1 # Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 import os | 5 import os |
| 6 | 6 |
| 7 APP_DIR = os.path.dirname(os.path.abspath(__file__)) | 7 APP_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 8 import google | 8 import google |
| 9 | 9 |
| 10 google.__path__.insert( | 10 google.__path__.insert( |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 def create_html_app(): # pragma: no cover | 26 def create_html_app(): # pragma: no cover |
| 27 """Returns WSGI app that serves HTML pages.""" | 27 """Returns WSGI app that serves HTML pages.""" |
| 28 app = webapp2.WSGIApplication( | 28 app = webapp2.WSGIApplication( |
| 29 handlers.get_frontend_routes(), debug=utils.is_local_dev_server()) | 29 handlers.get_frontend_routes(), debug=utils.is_local_dev_server()) |
| 30 gae_ts_mon.initialize(app, cron_module='backend') | 30 gae_ts_mon.initialize(app, cron_module='backend') |
| 31 return app | 31 return app |
| 32 | 32 |
| 33 | 33 |
| 34 def create_endpoints_app(): # pragma: no cover | 34 def create_endpoints_app(): # pragma: no cover |
| 35 """Returns WSGI app that serves cloud endpoints requests.""" | 35 """Returns WSGI app that serves cloud endpoints requests.""" |
| 36 return endpoints.api_server([api.BuildBucketApi, config.ConfigApi]) | 36 return endpoints.api_server([ |
| 37 api.BuildBucketApi, swarming.SwarmbucketApi, config.ConfigApi]) |
| 37 | 38 |
| 38 | 39 |
| 39 def create_backend_app(): # pragma: no cover | 40 def create_backend_app(): # pragma: no cover |
| 40 """Returns WSGI app for backend.""" | 41 """Returns WSGI app for backend.""" |
| 41 routes = handlers.get_backend_routes() + swarming.get_routes() | 42 routes = handlers.get_backend_routes() + swarming.get_routes() |
| 42 app = webapp2.WSGIApplication(routes, debug=utils.is_local_dev_server()) | 43 app = webapp2.WSGIApplication(routes, debug=utils.is_local_dev_server()) |
| 43 gae_ts_mon.initialize(app, cron_module='backend') | 44 gae_ts_mon.initialize(app, cron_module='backend') |
| 44 gae_ts_mon.register_global_metrics([ | 45 gae_ts_mon.register_global_metrics([ |
| 45 metrics.CURRENTLY_PENDING, | 46 metrics.CURRENTLY_PENDING, |
| 46 metrics.CURRENTLY_RUNNING, | 47 metrics.CURRENTLY_RUNNING, |
| 47 metrics.LEASE_LATENCY, | 48 metrics.LEASE_LATENCY, |
| 48 metrics.SCHEDULING_LATENCY, | 49 metrics.SCHEDULING_LATENCY, |
| 49 ]) | 50 ]) |
| 50 gae_ts_mon.register_global_metrics_callback( | 51 gae_ts_mon.register_global_metrics_callback( |
| 51 'send_metrics', metrics.send_all_metrics) | 52 'send_metrics', metrics.send_all_metrics) |
| 52 return app | 53 return app |
| 53 | 54 |
| 54 | 55 |
| 55 def initialize(): # pragma: no cover | 56 def initialize(): # pragma: no cover |
| 56 """Bootstraps the global state and creates WSGI applications.""" | 57 """Bootstraps the global state and creates WSGI applications.""" |
| 57 ereporter2.register_formatter() | 58 ereporter2.register_formatter() |
| 58 return create_html_app(), create_endpoints_app(), create_backend_app() | 59 return create_html_app(), create_endpoints_app(), create_backend_app() |
| OLD | NEW |