Example #1
0
class Server(ThreadWithExc):

    urls = (
            '/', 'index',
            '/put_links', 'put_links',
            '/kill', 'kill',
            '/stop', 'stop',
            '/alive', 'alive',
            '/stats', 'stats'
        )

    def __init__(self, port=8080, address='0.0.0.0'):
        super(Server, self).__init__()
        self.app = WebApplication(self.__class__.urls, globals())
        self.port = port
        self.address = address

    def run(self):
        try:
            self.app.run(port=self.port, address=self.address)
        finally:
            crawler.stop()
            event.set()

    def kill(self):
        self.app.stop()
        print "Crawler web app stop"
        exit(0)
Example #2
0
class Server(ThreadWithExc):

    urls = (
            '/', 'index',
            '/put_links', 'put_links',
            '/kill', 'kill',
            '/stop', 'stop',
            '/alive', 'alive',
            '/stats', 'stats'
        )

    def __init__(self, port=8080, address='0.0.0.0'):
        super(Server, self).__init__()
        self.app = WebApplication(self.__class__.urls, globals())
        self.port = port
        self.address = address

    def run(self):
        try:
            #TODO: check why sometimes something strange happens ('NoneType no attribute stop')
            self.app.run(port=self.port, address=self.address)
        finally:
            crawler.stop()
            event.set()

    def kill(self):
        self.app.stop()
        print "Server stop"
        exit(0)
Example #3
0
class WebServer(threading.Thread):

    def __init__(self, address='0.0.0.0', port=8800):
        threading.Thread.__init__(self)
        self.address = address
        self.port = port

        urls = (
            '/', 'index',
            '/feedback', 'feedback',
            '/put_data', 'put_data',
            '/crawlers', 'crawlers',
            '/speed', 'speed',
            '/update', 'update',
            '/get_data', 'get_data',
            '/alive', 'alive',
            '/stop', 'stop',
            '/kill', 'kill',
            '/stats', 'stats'
        )
        self.app = WebApplication(urls, globals())

    def run(self):
        try:
            self.app.run(address=self.address, port=self.port)
        finally:
            server.kill()

    def get_host(self):
        return '%s:%d' % (self.address, self.port)

    def stop(self):
        self.app.stop()
Example #4
0
class WebServer(threading.Thread):
    def __init__(self, address="0.0.0.0", port=8800):
        threading.Thread.__init__(self)
        self.address = address
        self.port = port

        urls = (
            "/",
            "index",
            "/feedback",
            "feedback",
            "/put_data",
            "put_data",
            "/crawlers",
            "crawlers",
            "/speed",
            "speed",
            "/update",
            "update",
            "/get_data",
            "get_data",
            "/alive",
            "alive",
            "/stop",
            "stop",
            "/kill",
            "kill",
            "/stats",
            "stats",
        )
        self.app = WebApplication(urls, globals())

    def run(self):
        try:
            self.app.run(address=self.address, port=self.port)
        finally:
            server.kill()

    def get_host(self):
        return "%s:%d" % (self.address, self.port)

    def stop(self):
        self.app.stop()