Beispiel #1
0
    def start(self, prom_port, prom_addr, use_test_thread=False):
        """Start webserver."""
        if not self.server:
            app = make_wsgi_app(self._reg)
            if use_test_thread:
                from wsgiref.simple_server import make_server, WSGIRequestHandler
                import threading

                class NoLoggingWSGIRequestHandler(WSGIRequestHandler):
                    """Don't log requests."""
                    def log_message(self, *_args):  # pylint: disable=arguments-differ
                        pass

                self.server = make_server(
                    prom_addr,
                    int(prom_port),
                    app,
                    handler_class=NoLoggingWSGIRequestHandler)
                self.thread = threading.Thread(
                    target=self.server.serve_forever)
                self.thread.daemon = True
                self.thread.start()
            else:
                self.server = hub.WSGIServer((prom_addr, int(prom_port)), app)
                self.thread = hub.spawn(self.server.serve_forever)
            self.thread.name = 'prometheus'
Beispiel #2
0
 def start(self, prom_port, prom_addr, use_test_thread=False):
     """Start webserver."""
     if not self.server:
         if use_test_thread:
             start_http_server(int(prom_port), prom_addr)
         else:
             app = make_wsgi_app()
             self.server = hub.WSGIServer((prom_addr, int(prom_port)), app)
             hub.spawn(self.server.serve_forever)
Beispiel #3
0
 def create_wsgi_app(self, host, port):
     wsgi = WSGIApplication()
     webapp = hub.WSGIServer((host, port), wsgi)
     hub.spawn(webapp.serve_forever)
     return wsgi