Beispiel #1
0
def t_http():
    try:
        server = HTTPServer(('0.0.0.0', PORT_NUMBER), myHandler)
        print 'Started httpserver on port ', PORT_NUMBER
        server.serve_forever()
    except:
        server.close()
Beispiel #2
0
def t_http():
    try:
        server = HTTPServer(('0.0.0.0', PORT_NUMBER), myHandler)
        print 'Started httpserver on port ' , PORT_NUMBER
        server.serve_forever()
    except:
        server.close()
Beispiel #3
0
def start_http(port):
    # Create the registry
    print "starting  port" + str(port)
    from prometheus_client.core import REGISTRY

    try:
        myCollector = MyCollector(port)
        reg = CollectorRegistry(auto_describe=True)
        reg.register(myCollector)

        def handler(*args, **kwargs):
            MyMetricHandler(reg, *args, **kwargs)

        #server=start_http_server(port,handler)
        #myCollector=MyCollector(port)
        #reg=CollectorRegistry(auto_describe=True)
        #reg.register(myCollector)
        server = HTTPServer(('', port), handler)
        server.serve_forever()
        #while True: time.sleep(1)
    except (KeyboardInterrupt, SystemExit):
        print "stop"
    finally:
        sys.exit(0)
        server.shutdown()
        server.close()
Beispiel #4
0
def main():
    try:
        port = 8080
        server = HTTPServer(('', port), WebServerHandler)
        print('Serve running on: %s' % port)
        server.serve_forever()
    except KeyboardInterrupt:
        print('^C entered, stopping web server...')
        server.close()
def start_http(port):
    try:
        print('Listening on localhost:%s' % port)
        server = HTTPServer(('', port), RequestHandler)
        server.serve_forever()
    except (KeyboardInterrupt, SystemExit):
        print "stop"
    finally:
        sys.exit(0)
        server.shutdown()
        server.close()
 def run(self):
     try:
         print('Listening on localhost:%s' % self.port)
         server = HTTPServer(('', self.port), RequestHandler)
         while self.serve:
             server.handle_request()
             self.counter = self.counter + 1
     except (KeyboardInterrupt, SystemExit):
         keep_running = False
         print "stop"
     finally:
         sys.exit(0)
         server.shutdown()
         server.close()
def start_http(port):
    global keep_running

    counter = 0
    try:
        print('Listening on localhost:%s' % port)
        server = HTTPServer(('', port), RequestHandler)
        while is_running():
            server.handle_request()
            counter = counter + 1

        print("port: " + str(port) + " count:" + str(counter))

    except (KeyboardInterrupt, SystemExit):
        keep_running = False
        print "stop"
    finally:
        sys.exit(0)
        server.shutdown()
        server.close()