def main():
    """Launch the API server."""
    # Parse command line options if present.
    tornado.options.parse_command_line()
    options = tornado.options.options

    # Bring in (server-wide) configuration information.
    try:
        import configparser         # Python 3.0
    except __HOLE__:
        import ConfigParser as configparser

    # Read configuration information.
    configfiles = [options.config,
                   os.path.join(sys.path[0], default_config_directory,
                                default_config_file)]
    cfg = configparser.ConfigParser()
    cfg.read(configfiles)

    # Sanity check.
    if not cfg.has_section(C.FRONT_END):
        error("Incomplete configuration information, tried:\n\t" +
              "\n\t".join(configfiles))

    # Allow command-line options to override the configuration file.
    if options.backend:
        cfg.set(C.DATASTORE, C.DATASTORE_BACKEND, options.backend)
    if options.encoding:
        cfg.set(C.DATASTORE, C.DATASTORE_ENCODING, options.encoding)

    # Load the desired interface to the datastore.
    backend = cfg.get(C.DATASTORE, C.DATASTORE_BACKEND)
    try:
        module = __import__('datastore.ds_' + backend, fromlist=['Datastore'])
        datastore = module.Datastore(cfg)
    except ImportError, x:
        error("Could not initialize datastore of type \"%s\": %s" %
              (backend, str(x)))

    # Initialize the OSM element factory and other modules.
    init_slabutil(cfg)
    init_osm_factory(cfg)

    # Create an instance of the front-end server.
    port = cfg.getint(C.FRONT_END, C.PORT)
    feserver = OSMFrontEndServer(cfg, options, datastore)
    http_server = tornado.httpserver.HTTPServer(feserver.application)
    http_server.listen(port)

    # Start the server.
    try:
        tornado.ioloop.IOLoop.instance().start()
    except KeyboardInterrupt:
        if options.verbose:
            pass                # Print statistics etc.

#
# Invoke main()
#
dataset/ETHPy150Open MapQuest/mapquest-osm-server/src/python/frontend/__main__.py/main