コード例 #1
0
  def main(_, opts):
    path_detector = FixedPathDetector(opts.root)
    task_observer = TaskObserver(path_detector)
    task_observer.start()
    server = configure_server(task_observer)

    thread = ExceptionalThread(target=lambda: server.run('0.0.0.0', opts.port, 'cherrypy'))
    thread.daemon = True
    thread.start()

    sleep_forever()
コード例 #2
0
ファイル: thermos_observer.py プロジェクト: songaal/aurora
    def main(_, opts):
        path_detector = FixedPathDetector(opts.root)
        task_observer = TaskObserver(path_detector)
        task_observer.start()
        server = configure_server(task_observer)

        thread = ExceptionalThread(
            target=lambda: server.run('0.0.0.0', opts.port, 'cherrypy'))
        thread.daemon = True
        thread.start()

        sleep_forever()
コード例 #3
0
def main(_, options):
  path_detector = ChainedPathDetector(
      FixedPathDetector(options.root),
      MesosPathDetector(options.mesos_root),
  )
  observer = TaskObserver(path_detector)
  observer.start()
  root_server = configure_server(observer)

  thread = ExceptionalThread(target=lambda: root_server.run('0.0.0.0', options.port, 'cherrypy'))
  thread.daemon = True
  thread.start()

  sleep_forever()
コード例 #4
0
ファイル: thermos_observer.py プロジェクト: songaal/aurora
def main(_, options):
    path_detector = ChainedPathDetector(
        FixedPathDetector(options.root),
        MesosPathDetector(options.mesos_root),
    )
    observer = TaskObserver(path_detector)
    observer.start()
    root_server = configure_server(observer)

    thread = ExceptionalThread(
        target=lambda: root_server.run('0.0.0.0', options.port, 'cherrypy'))
    thread.daemon = True
    thread.start()

    sleep_forever()
コード例 #5
0
  def test_run_loop(self):
    """Test observer run loop."""
    mock_task_detector = create_autospec(spec=ObserverTaskDetector)
    with patch(
        "apache.thermos.observer.task_observer.ObserverTaskDetector",
        return_value=mock_task_detector) as mock_detector:
      with patch('threading._Event.wait') as mock_wait:

        run_count = 3
        interval = 15
        observer = TaskObserver(mock_detector, interval=Amount(interval, Time.SECONDS))
        observer.start()
        while len(mock_wait.mock_calls) < run_count:
          pass

        observer.stop()

        assert len(mock_task_detector.mock_calls) >= run_count
        assert len(mock_wait.mock_calls) >= run_count
        args = mock_wait.mock_calls[1][1]
        assert interval == args[0]
コード例 #6
0
  def main(args, opts):
    if args:
      print("ERROR: unrecognized arguments: %s\n" % (" ".join(args)), file=sys.stderr)
      app.help()
      sys.exit(1)

    root_server = HttpServer()
    root_server.mount_routes(DiagnosticsEndpoints())

    task_observer = TaskObserver(opts.root)
    task_observer.start()

    bottle_wrapper = BottleObserver(task_observer)

    root_server.mount_routes(bottle_wrapper)

    def run():
      root_server.run('0.0.0.0', opts.port, 'cherrypy')

    et = ExceptionalThread(target=run)
    et.daemon = True
    et.start()
    et.join()
コード例 #7
0
    def test_run_loop(self):
        """Test observer run loop."""
        mock_task_detector = create_autospec(spec=ObserverTaskDetector)
        with patch(
                "apache.thermos.observer.task_observer.ObserverTaskDetector",
                return_value=mock_task_detector) as mock_detector:
            with patch('threading._Event.wait') as mock_wait:

                run_count = 3
                interval = 15
                observer = TaskObserver(mock_detector,
                                        interval=Amount(
                                            interval, Time.SECONDS))
                observer.start()
                while len(mock_wait.mock_calls) < run_count:
                    pass

                observer.stop()

                assert len(mock_task_detector.mock_calls) >= run_count
                assert len(mock_wait.mock_calls) >= run_count
                args = mock_wait.mock_calls[1][1]
                assert interval == args[0]
コード例 #8
0
    def main(args, opts):
        if args:
            print("ERROR: unrecognized arguments: %s\n" % (" ".join(args)),
                  file=sys.stderr)
            app.help()
            sys.exit(1)

        root_server = HttpServer()
        root_server.mount_routes(DiagnosticsEndpoints())

        task_observer = TaskObserver(opts.root)
        task_observer.start()

        bottle_wrapper = BottleObserver(task_observer)

        root_server.mount_routes(bottle_wrapper)

        def run():
            root_server.run('0.0.0.0', opts.port, 'cherrypy')

        et = ExceptionalThread(target=run)
        et.daemon = True
        et.start()
        et.join()