Beispiel #1
0
def start():
    """Starts the server"""
    os.umask(022)
    context.setup_loggers()
    context.main_logger.info("Starting Pushkin...")
    context.main_logger.info("Starting processors...")
    context.start_processors()

    # register server to termination signals so we can stop the server
    # otherwise, server runs until killed
    def shutdown_handler(signum, frame):
        context.main_logger.info("Stopping Pushkin...")
        print "Server stopped."
        exit_handler()
        sys.exit(0)

    @atexit.register
    def exit_handler():
        tornado.ioloop.IOLoop.instance().stop()

    signal.signal(signal.SIGINT, shutdown_handler)
    signal.signal(signal.SIGTERM, shutdown_handler)
    if os.name == 'nt':
        signal.signal(signal.SIGBREAK, shutdown_handler)
    else:
        signal.signal(signal.SIGQUIT, shutdown_handler)

    # start server
    server = tornado.httpserver.HTTPServer(create_app())
    server.bind(context.config.port)  # port
    server.start(1)
    context.main_logger.info("Pushkin has started")
    tornado.ioloop.IOLoop.instance().start()
Beispiel #2
0
def start():
    """Starts the server"""
    os.umask(022)
    context.setup_loggers()
    context.main_logger.info("Starting Pushkin...")
    context.main_logger.info("Starting processors...")
    context.start_processors()

    # register server to termination signals so we can stop the server
    # otherwise, server runs until killed
    def shutdown_handler(signum, frame):
        context.main_logger.info("Stopping Pushkin...")
        print "Server stopped."
        exit_handler()
        sys.exit(0)

    @atexit.register
    def exit_handler():
        tornado.ioloop.IOLoop.instance().stop()

    signal.signal(signal.SIGINT, shutdown_handler)
    signal.signal(signal.SIGTERM, shutdown_handler)
    if os.name == 'nt':
        signal.signal(signal.SIGBREAK, shutdown_handler)
    else:
        signal.signal(signal.SIGQUIT, shutdown_handler)

    # start server
    server = tornado.httpserver.HTTPServer(create_app())
    server.bind(context.config.port)  # port
    server.start(1)
    context.main_logger.info("Pushkin has started")
    tornado.ioloop.IOLoop.instance().start()