| OLD | NEW |
| 1 # Copyright 2013 The LUCI Authors. All rights reserved. | 1 # Copyright 2013 The LUCI Authors. All rights reserved. |
| 2 # Use of this source code is governed under the Apache License, Version 2.0 | 2 # Use of this source code is governed under the Apache License, Version 2.0 |
| 3 # that can be found in the LICENSE file. | 3 # that can be found in the LICENSE file. |
| 4 | 4 |
| 5 """This modules is imported by AppEngine and defines the 'app' object. | 5 """This modules is imported by AppEngine and defines the 'app' object. |
| 6 | 6 |
| 7 It is a separate file so that application bootstrapping code like ereporter2, | 7 It is a separate file so that application bootstrapping code like ereporter2, |
| 8 that shouldn't be done in unit tests, can be done safely. This file must be | 8 that shouldn't be done in unit tests, can be done safely. This file must be |
| 9 tested via a smoke test. | 9 tested via a smoke test. |
| 10 """ | 10 """ |
| 11 | 11 |
| 12 import os | 12 import os |
| 13 import sys | 13 import sys |
| 14 | 14 |
| 15 import endpoints | 15 import endpoints |
| 16 import gae_ts_mon | 16 import gae_ts_mon |
| 17 | 17 |
| 18 APP_DIR = os.path.dirname(os.path.abspath(__file__)) | 18 APP_DIR = os.path.dirname(os.path.abspath(__file__)) |
| 19 sys.path.insert(0, os.path.join(APP_DIR, 'components', 'third_party')) | 19 sys.path.insert(0, os.path.join(APP_DIR, 'components', 'third_party')) |
| 20 | 20 |
| 21 from components import ereporter2 | 21 from components import ereporter2 |
| 22 | 22 |
| 23 import handlers_endpoints | 23 import handlers_endpoints |
| 24 import handlers_frontend | 24 import handlers_frontend |
| 25 import event_mon_metrics |
| 25 import ts_mon_metrics | 26 import ts_mon_metrics |
| 26 from server import config | 27 from server import config |
| 27 | 28 |
| 28 | 29 |
| 29 def create_application(): | 30 def create_application(): |
| 30 ereporter2.register_formatter() | 31 ereporter2.register_formatter() |
| 31 | 32 |
| 32 def is_enabled_callback(): | 33 def is_enabled_callback(): |
| 33 return config.settings().enable_ts_monitoring | 34 return config.settings().enable_ts_monitoring |
| 34 | 35 |
| 35 # App that serves HTML pages and old API. | 36 # App that serves HTML pages and old API. |
| 36 frontend_app = handlers_frontend.create_application(False) | 37 frontend_app = handlers_frontend.create_application(False) |
| 37 gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback) | 38 gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback) |
| 38 # Local import, because it instantiates the mapreduce app. | 39 # Local import, because it instantiates the mapreduce app. |
| 39 from mapreduce import main | 40 from mapreduce import main |
| 40 gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback) | 41 gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback) |
| 41 | 42 |
| 42 # TODO(maruel): Remove this once there is no known client anymore. | 43 # TODO(maruel): Remove this once there is no known client anymore. |
| 43 api = endpoints.api_server([ | 44 api = endpoints.api_server([ |
| 44 handlers_endpoints.swarming_api, | 45 handlers_endpoints.swarming_api, |
| 45 # components.config endpoints for validation and configuring of luci-config | 46 # components.config endpoints for validation and configuring of luci-config |
| 46 # service URL. | 47 # service URL. |
| 47 config.ConfigApi, | 48 config.ConfigApi, |
| 48 ]) | 49 ]) |
| 49 | 50 |
| 51 event_mon_metrics.initialize() |
| 50 ts_mon_metrics.initialize() | 52 ts_mon_metrics.initialize() |
| 51 return frontend_app, api, main.APP | 53 return frontend_app, api, main.APP |
| 52 | 54 |
| 53 | 55 |
| 54 app, endpoints_app, mapreduce_app = create_application() | 56 app, endpoints_app, mapreduce_app = create_application() |
| OLD | NEW |