| 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( |
| 11 0, os.path.join(APP_DIR, 'components', 'third_party', 'protobuf', 'google')) | 11 0, os.path.join(APP_DIR, 'components', 'third_party', 'protobuf', 'google')) |
| 12 | 12 |
| 13 from components import config | 13 from components import config |
| 14 from components import ereporter2 | 14 from components import ereporter2 |
| 15 from components import utils | 15 from components import utils |
| 16 import endpoints | 16 import endpoints |
| 17 import gae_ts_mon |
| 17 import webapp2 | 18 import webapp2 |
| 18 | 19 |
| 19 import api | 20 import api |
| 20 import handlers | 21 import handlers |
| 21 import swarming | 22 import swarming |
| 22 | 23 |
| 23 | 24 |
| 24 def create_html_app(): # pragma: no cover | 25 def create_html_app(): # pragma: no cover |
| 25 """Returns WSGI app that serves HTML pages.""" | 26 """Returns WSGI app that serves HTML pages.""" |
| 26 return webapp2.WSGIApplication( | 27 app = webapp2.WSGIApplication( |
| 27 handlers.get_frontend_routes(), debug=utils.is_local_dev_server()) | 28 handlers.get_frontend_routes(), debug=utils.is_local_dev_server()) |
| 29 gae_ts_mon.initialize(app) |
| 30 return app |
| 28 | 31 |
| 29 | 32 |
| 30 def create_endpoints_app(): # pragma: no cover | 33 def create_endpoints_app(): # pragma: no cover |
| 31 """Returns WSGI app that serves cloud endpoints requests.""" | 34 """Returns WSGI app that serves cloud endpoints requests.""" |
| 32 return endpoints.api_server([api.BuildBucketApi, config.ConfigApi]) | 35 return endpoints.api_server([api.BuildBucketApi, config.ConfigApi]) |
| 33 | 36 |
| 34 | 37 |
| 35 def create_backend_app(): # pragma: no cover | 38 def create_backend_app(): # pragma: no cover |
| 36 """Returns WSGI app for backend.""" | 39 """Returns WSGI app for backend.""" |
| 37 routes = handlers.get_backend_routes() + swarming.get_routes() | 40 routes = handlers.get_backend_routes() + swarming.get_routes() |
| 38 return webapp2.WSGIApplication( | 41 app = webapp2.WSGIApplication(routes, debug=utils.is_local_dev_server()) |
| 39 routes, debug=utils.is_local_dev_server()) | 42 gae_ts_mon.initialize(app) |
| 43 return app |
| 40 | 44 |
| 41 | 45 |
| 42 def initialize(): # pragma: no cover | 46 def initialize(): # pragma: no cover |
| 43 """Bootstraps the global state and creates WSGI applications.""" | 47 """Bootstraps the global state and creates WSGI applications.""" |
| 44 ereporter2.register_formatter() | 48 ereporter2.register_formatter() |
| 45 return create_html_app(), create_endpoints_app(), create_backend_app() | 49 return create_html_app(), create_endpoints_app(), create_backend_app() |
| OLD | NEW |