Example #1
0
def run():
    """Runs web service.

    """
    log("Initializing")

    # Run web-service.
    app = _get_app()
    app.listen(config.port)
    log("Ready")
    tornado.ioloop.IOLoop.instance().start()
Example #2
0
def _log_error(ctx):
    """Write processing error message to standard output.

    """
    # Escape if processing a controlled loop exit.
    if isinstance(ctx.error, StopIteration):
        return

    msg = "INGEST ERROR :: {0} :: {1} :: {2}"
    msg = msg.format(ctx, type(ctx.error), ctx.error)
    logger.log(msg)
Example #3
0
def _get_app():
    """Returns application instance.

    """
    # Initialise archive usage.
    pyesdoc.archive.init()

    # Get endpoints.
    endpoints = _get_app_endpoints()
    log("Endpoint to handler mappings:")
    for url, handler in sorted(endpoints, key=lambda i: i[0]):
        log("{0} ---> {1}".format(url, str(handler).split(".")[-1][0:-2]))

    # Initialise JSON schemas.
    schemas.init([i[0] for i in endpoints])

    # Convert endpoints to tornado URLSpec instances.
    endpoints = [tornado.web.url(i[0], i[1]) for i in endpoints]

    # Return app instance.
    return tornado.web.Application(endpoints,
                                   debug=(config.mode == 'dev'),
                                   **_get_app_settings())
Example #4
0
def _log(msg):
    """Writes a log message.

    """
    logger.log("INDEXING :: {0} ...".format(msg))