Ejemplo n.º 1
0
    def run_server(reporting_queue):
      def report_launch(actual_port):
        reporting_queue.put(
          'Launching server with pid {pid} at http://localhost:{port}'
          .format(pid=os.getpid(), port=actual_port))

      def done_reporting():
        reporting_queue.put(DONE)

      try:
        # We mustn't block in the child, because the multiprocessing module enforces that the
        # parent either kills or joins to it. Instead we fork a grandchild that inherits the queue
        # but is allowed to block indefinitely on the server loop.
        if not os.fork():
          # Child process.
          # The server finds run-specific info dirs by looking at the subdirectories of info_dir,
          # which is conveniently and obviously the parent dir of the current run's info dir.
          info_dir = os.path.dirname(self.context.run_tracker.run_info_dir)
          # If these are specified explicitly in the config, use those. Otherwise
          # they will be None, and we'll use the ones baked into this package.
          template_dir = self.get_options().template_dir
          assets_dir = self.get_options().assets_dir
          settings = ReportingServer.Settings(info_dir=info_dir, template_dir=template_dir,
                                              assets_dir=assets_dir, root=get_buildroot(),
                                              allowed_clients=self.get_options().allowed_clients)
          server = ReportingServer(self.get_options().port, settings)
          actual_port = server.server_port()
          ReportingServerManager.save_current_server_port(actual_port)
          report_launch(actual_port)
          done_reporting()
          # Block forever here.
          server.start()
      except socket.error:
        done_reporting()
        raise
Ejemplo n.º 2
0
    def run_server(reporting_queue):
      def report_launch(actual_port):
        reporting_queue.put(
          'Launching server with pid %d at http://localhost:%d' % (os.getpid(), actual_port))

      def done_reporting():
        reporting_queue.put(DONE)

      try:
        # We mustn't block in the child, because the multiprocessing module enforces that the
        # parent either kills or joins to it. Instead we fork a grandchild that inherits the queue
        # but is allowed to block indefinitely on the server loop.
        if not os.fork():
          # Child process.
          info_dir = RunInfo.dir(self.context.config)
          # If these are specified explicitly in the config, use those. Otherwise
          # they will be None, and we'll use the ones baked into this package.
          template_dir = self.context.config.get('reporting', 'reports_template_dir')
          assets_dir = self.context.config.get('reporting', 'reports_assets_dir')
          settings = ReportingServer.Settings(info_dir=info_dir, template_dir=template_dir,
                                              assets_dir=assets_dir, root=get_buildroot(),
                                              allowed_clients=self.context.options.allowed_clients)
          server = ReportingServer(self.context.options.port, settings)
          actual_port = server.server_port()
          ReportingServerManager.save_current_server_port(actual_port)
          report_launch(actual_port)
          done_reporting()
          # Block forever here.
          server.start()
      except socket.error:
        done_reporting()
        raise
Ejemplo n.º 3
0
    def run_server(reporting_queue):
      def report_launch(actual_port):
        reporting_queue.put(
          'Launching server with pid %d at http://localhost:%d' % (os.getpid(), actual_port))

      def done_reporting():
        reporting_queue.put(DONE)

      try:
        # We mustn't block in the child, because the multiprocessing module enforces that the
        # parent either kills or joins to it. Instead we fork a grandchild that inherits the queue
        # but is allowed to block indefinitely on the server loop.
        if not os.fork():
          # Child process.
          info_dir = RunInfo.dir(self.context.config)
          # If these are specified explicitly in the config, use those. Otherwise
          # they will be None, and we'll use the ones baked into this package.
          template_dir = self.context.config.get('reporting', 'reports_template_dir')
          assets_dir = self.context.config.get('reporting', 'reports_assets_dir')
          settings = ReportingServer.Settings(info_dir=info_dir, template_dir=template_dir,
                                              assets_dir=assets_dir, root=get_buildroot(),
                                              allowed_clients=self.context.options.allowed_clients)
          server = ReportingServer(self.context.options.port, settings)
          actual_port = server.server_port()
          ReportingServerManager.save_current_server_port(actual_port)
          report_launch(actual_port)
          done_reporting()
          # Block forever here.
          server.start()
      except socket.error:
        done_reporting()
        raise
Ejemplo n.º 4
0
 def __init__(self, request, client_address, server):
   super().__init__(
     settings=ReportingServer.Settings(
       info_dir=dir,
       template_dir=dir,
       assets_dir=dir,
       root=dir,
       allowed_clients=['ALL'],
     ),
     renderer=None,
     request=request,
     client_address=client_address,
     server=server,
   )
Ejemplo n.º 5
0
 def __init__(self, request, client_address, server):
     # TODO(6071): BaseHTTPServer.BaseHTTPRequestHandler is an old-style class, so we must
     # invoke its __init__ like this.
     # This will become unnecessary when we no longer support python2.
     PantsHandler.__init__(
         self,
         settings=ReportingServer.Settings(
             info_dir=dir,
             template_dir=dir,
             assets_dir=dir,
             root=dir,
             allowed_clients=['ALL'],
         ),
         renderer=None,
         request=request,
         client_address=client_address,
         server=server,
     )
Ejemplo n.º 6
0
        def run_server(reporting_queue):
            def report_launch(actual_port):
                reporting_queue.put(
                    'Launching server with pid {pid} at http://localhost:{port}'
                    .format(pid=os.getpid(), port=actual_port))

            def done_reporting():
                reporting_queue.put(DONE)

            try:
                # We mustn't block in the child, because the multiprocessing module enforces that the
                # parent either kills or joins to it. Instead we fork a grandchild that inherits the queue
                # but is allowed to block indefinitely on the server loop.
                if not os.fork():
                    # Child process.
                    # The server finds run-specific info dirs by looking at the subdirectories of info_dir,
                    # which is conveniently and obviously the parent dir of the current run's info dir.
                    info_dir = os.path.dirname(
                        self.context.run_tracker.run_info_dir)
                    # If these are specified explicitly in the config, use those. Otherwise
                    # they will be None, and we'll use the ones baked into this package.
                    template_dir = self.get_options().template_dir
                    assets_dir = self.get_options().assets_dir
                    settings = ReportingServer.Settings(
                        info_dir=info_dir,
                        template_dir=template_dir,
                        assets_dir=assets_dir,
                        root=get_buildroot(),
                        allowed_clients=self.get_options().allowed_clients)
                    server = ReportingServer(self.get_options().port, settings)
                    actual_port = server.server_port()
                    ReportingServerManager.save_current_server_port(
                        actual_port)
                    report_launch(actual_port)
                    done_reporting()
                    # Block forever here.
                    server.start()
            except socket.error:
                done_reporting()
                raise