Пример #1
0
def main():
    try:
        extra_options()
        configure()
        if options.mongrel:
            # install the zmq version of the IOLoop
            ioloop = IOLoop.instance()
            ioloop.install()
        else:
            ioloop = tornado.ioloop.IOLoop.instance()
        db = Database('blog', (options.couchdb_user, options.couchdb_password))
        db = CouchDBAdapter(db)
        if not db:
            logging.error("Failed to connect to DB:%s", options.couchdb_database)
            sys.exit(1)
        if options.mongrel:
            handler = Mongrel2Handler(StockApp(db), "tcp://127.0.0.1:8000",
                                      "tcp://127.0.0.1:8001",
                                      no_keep_alive=True)
            handler.start()
        else:
            http_server = tornado.httpserver.HTTPServer(StockApp(db), xheaders=True)
            http_server.listen(options.port)
        logging.info(
            "Starting " + options.site_name + " @ port:" + str(options.port))
        sys.excepthook = debug
        ioloop.start()
        ipython_thread.join()
    except KeyboardInterrupt:
        logging.info("Exiting cleanly on KeyboardInterrupt")
    except Exception as e:
        logging.exception(e)
Пример #2
0
    def __init__(self, request_callback, pull_addr, pub_addr, io_loop=None,
            zmq_ctx=None, sender_id=None, xheaders=True, no_keep_alive=False):

        self.request_callback = request_callback
        self.io_loop = io_loop or IOLoop.instance()
        self.sender_id = sender_id or str(uuid.uuid4())
        self.xheaders = xheaders
        self.no_keep_alive = no_keep_alive

        self._zmq_context = zmq_ctx or zmq.Context()
        self._listening_stream = self._create_listening_stream(pull_addr)
        self._sending_stream = self._create_sending_stream(pub_addr)
        self._started = False
Пример #3
0
    def __init__(self,
                 request_callback,
                 pull_addr,
                 pub_addr,
                 io_loop=None,
                 zmq_ctx=None,
                 sender_id=None,
                 xheaders=True,
                 no_keep_alive=False):

        self.request_callback = request_callback
        self.io_loop = io_loop or IOLoop.instance()
        self.sender_id = sender_id or str(uuid.uuid4())
        self.xheaders = xheaders
        self.no_keep_alive = no_keep_alive

        self._zmq_context = zmq_ctx or zmq.Context()
        self._listening_stream = self._create_listening_stream(pull_addr)
        self._sending_stream = self._create_sending_stream(pub_addr)
        self._started = False