Ejemplo n.º 1
0
def main():
    """Start and run the dispatcher."""
    parser = argparse.ArgumentParser()
    parser.add_argument("config_file",
                        help="The configuration file to run on.")
    parser.add_argument("-l",
                        "--log",
                        help="The file to log to. stdout otherwise.")
    parser.add_argument(
        "-c",
        "--log-config",
        help="Log config file to use instead of the standard logging.")
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbosity",
        action="count",
        default=0,
        help="Verbosity (between 1 and 2 occurrences with more leading to more "
        "verbose logging). WARN=0, INFO=1, "
        "DEBUG=2. This is overridden by the log config file if specified.")
    parser.add_argument(
        "-p",
        "--publish-port",
        type=int,
        dest="pub_port",
        nargs='?',
        const=0,
        default=None,
        help="Publish messages for dispatched files on this port. "
        "Default: no publishing.")
    parser.add_argument("-n",
                        "--publish-nameserver",
                        nargs='*',
                        dest="pub_nameservers",
                        help="Nameserver for publisher to connect to")
    cmd_args = parser.parse_args()
    setup_logging(cmd_args)
    logger.info("Starting up.")

    try:
        dispatcher = Dispatcher(cmd_args.config_file,
                                publish_port=cmd_args.pub_port,
                                publish_nameservers=cmd_args.pub_nameservers)
    except Exception as err:
        logger.error('Dispatcher crashed: %s', str(err))
        sys.exit(1)
    try:
        dispatcher.start()
        dispatcher.join()
    except KeyboardInterrupt:
        logger.debug("Interrupting")
    finally:
        dispatcher.close()
Ejemplo n.º 2
0
def main():
    """Start and run the dispatcher."""
    cmd_args = parse_args()
    setup_logging(cmd_args)
    logger.info("Starting up.")

    try:
        dispatcher = Dispatcher(cmd_args.config_file,
                                publish_port=cmd_args.pub_port,
                                publish_nameservers=cmd_args.pub_nameservers)
    except Exception as err:
        logger.error('Dispatcher crashed: %s', str(err))
        sys.exit(1)
    try:
        dispatcher.start()
        dispatcher.join()
    except KeyboardInterrupt:
        logger.debug("Interrupting")
    finally:
        dispatcher.close()
Ejemplo n.º 3
0
def main():
    """Start and run the dispatcher."""
    parser = argparse.ArgumentParser()
    parser.add_argument("config_file",
                        help="The configuration file to run on.")
    parser.add_argument("-l",
                        "--log",
                        help="The file to log to. stdout otherwise.")
    parser.add_argument(
        "-c",
        "--log-config",
        help="Log config file to use instead of the standard logging.")
    parser.add_argument(
        "-v",
        "--verbose",
        dest="verbosity",
        action="count",
        default=0,
        help="Verbosity (between 1 and 2 occurrences with more leading to more "
        "verbose logging). WARN=0, INFO=1, "
        "DEBUG=2. This is overridden by the log config file if specified.")
    cmd_args = parser.parse_args()

    setup_logging(cmd_args)
    logger.info("Starting up.")

    try:
        dispatcher = Dispatcher(cmd_args.config_file)
    except Exception as err:
        logger.error('Dispatcher crashed: %s', str(err))
        sys.exit(1)
    try:
        dispatcher.start()
        dispatcher.join()
    except KeyboardInterrupt:
        logger.debug("Interrupting")
    finally:
        dispatcher.close()