Exemplo n.º 1
0
def create_application():
  ereporter2.register_formatter()

  # Zap out the ndb in-process cache by default.
  # This cache causes excessive memory usage in in handler where a lot of
  # entities are fetched in one query. When coupled with high concurrency
  # as specified via max_concurrent_requests in app.yaml, this may cause out of
  # memory errors.
  ndb.Context.default_cache_policy = staticmethod(lambda _key: False)
  ndb.Context._cache_policy = staticmethod(lambda _key: False)

  # If running on a local dev server, allow bots to connect without prior
  # groups configuration. Useful when running smoke test.
  if utils.is_local_dev_server():
    acl.bootstrap_dev_server_acls()
    pools_config.bootstrap_dev_server_acls()

  def is_enabled_callback():
    return config.settings().enable_ts_monitoring

  backend_app = handlers_backend.create_application(False)
  gae_ts_mon.initialize(backend_app, is_enabled_fn=is_enabled_callback)

  # Local import, because it instantiates the mapreduce app.
  # This is for the task queue handlers.
  from mapreduce import main
  gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)

  event_mon_metrics.initialize()
  ts_mon_metrics.initialize()
  utils.report_memory(backend_app)
  return backend_app, main.APP
Exemplo n.º 2
0
def create_application():
    ereporter2.register_formatter()
    # Task queues must be sent to the backend.
    utils.set_task_queue_module('backend')
    template.bootstrap()

    # Zap out the ndb in-process cache by default.
    # This cache causes excessive memory usage in in handler where a lot of
    # entities are fetched in one query. When coupled with high concurrency
    # as specified via max_concurrent_requests in app.yaml, this may cause out of
    # memory errors.
    ndb.Context.default_cache_policy = staticmethod(lambda _key: False)
    ndb.Context._cache_policy = staticmethod(lambda _key: False)

    # If running on a local dev server, allow bots to connect without prior
    # groups configuration. Useful when running smoke test.
    if utils.is_local_dev_server():
        acl.bootstrap_dev_server_acls()
        pools_config.bootstrap_dev_server_acls()

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    # App that serves HTML pages and old API.
    frontend_app = handlers_frontend.create_application(False)
    gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback)

    endpoints_api = endpoints_webapp2.api_server([
        handlers_endpoints.SwarmingServerService,
        handlers_endpoints.SwarmingTaskService,
        handlers_endpoints.SwarmingTasksService,
        handlers_endpoints.SwarmingQueuesService,
        handlers_endpoints.SwarmingBotService,
        handlers_endpoints.SwarmingBotsService,
        # components.config endpoints for validation and configuring of luci-config
        # service URL.
        config.ConfigApi,
    ])

    prpc_api = webapp2.WSGIApplication(handlers_prpc.get_routes())

    # Local import, because it instantiates the mapreduce app.
    # This is for the Web UI.
    from mapreduce import main
    gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)

    event_mon_metrics.initialize()
    ts_mon_metrics.initialize()
    utils.report_memory(frontend_app)
    utils.report_memory(endpoints_api)
    utils.report_memory(prpc_api)
    return frontend_app, endpoints_api, prpc_api, main.APP
Exemplo n.º 3
0
def create_application(debug):
  template.bootstrap()
  utils.set_task_queue_module('default')

  routes = [
      # Frontend pages. They return HTML.
      # Public pages.
      ('/oldui', OldUIHandler),
      ('/stats', stats_gviz.StatsSummaryHandler),
      ('/<page:(bot|botlist|task|tasklist|)>', UIHandler),

      # User pages.
      ('/user/tasks', TasksHandler),
      ('/user/task/<task_id:[0-9a-fA-F]+>', TaskHandler),
      ('/user/task/<task_id:[0-9a-fA-F]+>/cancel', TaskCancelHandler),
      ('/user/task/<task_id:[0-9a-fA-F]+>/retry', TaskRetryHandler),

      # Privileged user pages.
      ('/restricted/bots', BotsListHandler),
      ('/restricted/bot/<bot_id:[^/]+>', BotHandler),
      ('/restricted/bot/<bot_id:[^/]+>/delete', BotDeleteHandler),

      # Admin pages.
      ('/restricted/config', RestrictedConfigHandler),
      ('/restricted/cancel_pending', RestrictedCancelPendingHandler),
      ('/restricted/upload/bot_config', UploadBotConfigHandler),
      ('/restricted/upload/bootstrap', UploadBootstrapHandler),

      # Mapreduce related urls.
      (r'/restricted/launch_mapreduce', RestrictedLaunchMapReduceJob),

      # The new APIs:
      ('/swarming/api/v1/stats/summary/<resolution:[a-z]+>',
        stats_gviz.StatsGvizSummaryHandler),
      ('/swarming/api/v1/stats/dimensions/<dimensions:.+>/<resolution:[a-z]+>',
        stats_gviz.StatsGvizDimensionsHandler),

      ('/_ah/mail/<to:.+>', EmailHandler),
      ('/_ah/warmup', WarmupHandler),
  ]
  routes = [webapp2.Route(*i) for i in routes]

  # If running on a local dev server, allow bots to connect without prior
  # groups configuration. Useful when running smoke test.
  if utils.is_local_dev_server():
    acl.bootstrap_dev_server_acls()

  routes.extend(handlers_backend.get_routes())
  routes.extend(handlers_bot.get_routes())
  routes.extend(handlers_endpoints.get_routes())
  return webapp2.WSGIApplication(routes, debug=debug)
Exemplo n.º 4
0
def create_application(debug):
  template.bootstrap()
  utils.set_task_queue_module('default')

  routes = [
      # Frontend pages. They return HTML.
      # Public pages.
      ('/', RootHandler),
      ('/stats', stats_gviz.StatsSummaryHandler),

      # User pages.
      ('/user/tasks', TasksHandler),
      ('/user/task/<task_id:[0-9a-fA-F]+>', TaskHandler),
      ('/user/task/<task_id:[0-9a-fA-F]+>/retry', TaskRetryHandler),
      ('/user/tasks/cancel', TaskCancelHandler),

      # Privileged user pages.
      ('/restricted/bots', BotsListHandler),
      ('/restricted/bot/<bot_id:[^/]+>', BotHandler),
      ('/restricted/bot/<bot_id:[^/]+>/delete', BotDeleteHandler),

      # Admin pages.
      ('/restricted/config', RestrictedConfigHandler),
      ('/restricted/upload/bot_config', UploadBotConfigHandler),
      ('/restricted/upload/bootstrap', UploadBootstrapHandler),

      # Mapreduce related urls.
      (r'/restricted/launch_mapreduce', RestrictedLaunchMapReduceJob),

      # The new APIs:
      ('/swarming/api/v1/stats/summary/<resolution:[a-z]+>',
        stats_gviz.StatsGvizSummaryHandler),
      ('/swarming/api/v1/stats/dimensions/<dimensions:.+>/<resolution:[a-z]+>',
        stats_gviz.StatsGvizDimensionsHandler),

      ('/_ah/mail/<to:.+>', EmailHandler),
      ('/_ah/warmup', WarmupHandler),
  ]
  routes = [webapp2.Route(*i) for i in routes]

  # If running on a local dev server, allow bots to connect without prior
  # groups configuration. Useful when running smoke test.
  if utils.is_local_dev_server():
    acl.bootstrap_dev_server_acls()

  # TODO(maruel): Split backend into a separate module. For now add routes here.
  routes.extend(handlers_backend.get_routes())
  routes.extend(handlers_api.get_routes())
  routes.extend(handlers_bot.get_routes())

  return webapp2.WSGIApplication(routes, debug=debug)
Exemplo n.º 5
0
def create_application():
    ereporter2.register_formatter()
    utils.set_task_queue_module('backend')
    template.bootstrap()

    # If running on a local dev server, allow bots to connect without prior
    # groups configuration. Useful when running smoke test.
    if utils.is_local_dev_server():
        acl.bootstrap_dev_server_acls()

    def is_enabled_callback():
        return config.settings().enable_ts_monitoring

    # App that serves HTML pages and old API.
    frontend_app = handlers_frontend.create_application(False)
    gae_ts_mon.initialize(frontend_app, is_enabled_fn=is_enabled_callback)

    # App that contains crons and task queues.
    backend_app = handlers_backend.create_application(False)
    gae_ts_mon.initialize(backend_app, is_enabled_fn=is_enabled_callback)

    # Local import, because it instantiates the mapreduce app.
    from mapreduce import main
    gae_ts_mon.initialize(main.APP, is_enabled_fn=is_enabled_callback)

    # TODO(maruel): Remove this once there is no known client anymore.
    api = webapp2.WSGIApplication(
        endpoints_webapp2.api_server(
            [
                handlers_endpoints.SwarmingServerService,
                handlers_endpoints.SwarmingTaskService,
                handlers_endpoints.SwarmingTasksService,
                handlers_endpoints.SwarmingQueuesService,
                handlers_endpoints.SwarmingBotService,
                handlers_endpoints.SwarmingBotsService,
                # components.config endpoints for validation and configuring of luci-config
                # service URL.
                config.ConfigApi,
            ],
            base_path='/_ah/api'))

    event_mon_metrics.initialize()
    ts_mon_metrics.initialize()
    return frontend_app, api, backend_app, main.APP