def main(args=sys.argv):
    from powerhose.util import set_logger, resolve_name

    parser = argparse.ArgumentParser(description='Run a Powerhose cluster.')

    parser.add_argument('--frontend',
                        dest='frontend',
                        default=DEFAULT_FRONTEND,
                        help="ZMQ socket to receive jobs.")

    parser.add_argument('--backend',
                        dest='backend',
                        default=DEFAULT_BACKEND,
                        help="ZMQ socket for workers.")

    parser.add_argument('--heartbeat',
                        dest='heartbeat',
                        default=DEFAULT_HEARTBEAT,
                        help="ZMQ socket for the heartbeat.")

    parser.add_argument('target', help="Fully qualified name of the callable.")

    parser.add_argument('--debug',
                        action='store_true',
                        default=False,
                        help="Debug mode")

    parser.add_argument('--numprocesses',
                        dest='numprocesses',
                        default=5,
                        help="Number of processes to run.")

    parser.add_argument('--logfile',
                        dest='logfile',
                        default='stdout',
                        help="File to log in to .")

    args = parser.parse_args()

    set_logger(args.debug, 'powerhose', args.logfile)
    set_logger(args.debug, 'circus', args.logfile)
    sys.path.insert(0, os.getcwd())  # XXX
    resolve_name(args.target)  # check the callable

    cluster = get_cluster(args.target,
                          args.numprocesses,
                          frontend=args.frontend,
                          backend=args.backend,
                          heartbeat=args.heartbeat,
                          logfile=args.logfile,
                          debug=args.debug)
    try:
        cluster.start()
    except KeyboardInterrupt:
        pass
    finally:
        cluster.stop()
Ejemplo n.º 2
0
def main(args=sys.argv):
    from powerhose.util import set_logger, resolve_name

    parser = argparse.ArgumentParser(description='Run a Powerhose cluster.')

    parser.add_argument('--frontend', dest='frontend',
                        default=DEFAULT_FRONTEND,
                        help="ZMQ socket to receive jobs.")

    parser.add_argument('--backend', dest='backend',
                        default=DEFAULT_BACKEND,
                        help="ZMQ socket for workers.")

    parser.add_argument('--heartbeat', dest='heartbeat',
                        default=DEFAULT_HEARTBEAT,
                        help="ZMQ socket for the heartbeat.")

    parser.add_argument('target', help="Fully qualified name of the callable.")

    parser.add_argument('--debug', action='store_true', default=False,
                        help="Debug mode")

    parser.add_argument('--numprocesses', dest='numprocesses', default=5,
                        help="Number of processes to run.")

    parser.add_argument('--logfile', dest='logfile', default='stdout',
                        help="File to log in to .")

    args = parser.parse_args()

    set_logger(args.debug, 'powerhose', args.logfile)
    set_logger(args.debug, 'circus', args.logfile)
    sys.path.insert(0, os.getcwd())  # XXX
    resolve_name(args.target)  # check the callable

    cluster = get_cluster(args.target, args.numprocesses,
                          frontend=args.frontend, backend=args.backend,
                          heartbeat=args.heartbeat, logfile=args.logfile,
                          debug=args.debug)
    try:
        cluster.start()
    except KeyboardInterrupt:
        pass
    finally:
        cluster.stop()
Ejemplo n.º 3
0
def main(args=sys.argv):

    parser = argparse.ArgumentParser(description='Run some watchers.')

    parser.add_argument('--backend', dest='backend',
                        default=DEFAULT_BACKEND,
                        help="ZMQ socket to the broker.")

    parser.add_argument('target', help="Fully qualified name of the callable.")

    parser.add_argument('--debug', action='store_true', default=False,
                        help="Debug mode")

    parser.add_argument('--logfile', dest='logfile', default='stdout',
                        help="File to log in to.")

    parser.add_argument('--heartbeat', dest='heartbeat',
                        default=DEFAULT_HEARTBEAT,
                        help="ZMQ socket for the heartbeat.")

    parser.add_argument('--params', dest='params', default=None,
                        help='The parameters to be used in the worker.')

    parser.add_argument('--timeout', dest='timeout', type=float,
                        default=DEFAULT_TIMEOUT_MOVF,
                        help=('The maximum time allowed before the thread '
                              'stacks is dump and the job result not sent '
                              'back.'))

    args = parser.parse_args()
    set_logger(args.debug, logfile=args.logfile)
    sys.path.insert(0, os.getcwd())  # XXX
    target = resolve_name(args.target)
    if args.params is None:
        params = {}
    else:
        params = decode_params(args.params)

    logger.info('Worker registers at %s' % args.backend)
    logger.info('The heartbeat socket is at %r' % args.heartbeat)
    worker = Worker(target, backend=args.backend, heartbeat=args.heartbeat,
                    params=params, timeout=args.timeout)

    try:
        worker.start()
    except KeyboardInterrupt:
        return 1
    finally:
        worker.stop()

    return 0
Ejemplo n.º 4
0
def main(args=sys.argv):

    parser = argparse.ArgumentParser(description='Run some watchers.')

    parser.add_argument('--backend', dest='backend',
                        default=DEFAULT_BACKEND,
                        help="ZMQ socket to the broker.")

    parser.add_argument('target', help="Fully qualified name of the callable.")

    parser.add_argument('--debug', action='store_true', default=False,
                        help="Debug mode")

    parser.add_argument('--logfile', dest='logfile', default='stdout',
                        help="File to log in to.")

    parser.add_argument('--heartbeat', dest='heartbeat',
                        default=DEFAULT_HEARTBEAT,
                        help="ZMQ socket for the heartbeat.")

    parser.add_argument('--params', dest='params', default=None,
                        help='The parameters to be used in the worker.')

    parser.add_argument('--timeout', dest='timeout', type=float,
                        default=DEFAULT_TIMEOUT_MOVF,
                        help=('The maximum time allowed before the thread '
                              'stacks is dump and the job result not sent '
                              'back.'))

    parser.add_argument('--max-age', dest='max_age', type=float,
                        default=DEFAULT_MAX_AGE,
                        help=('The maximum age for a worker in seconds. '
                              'After that delay, the worker will simply quit. '
                              'When set to -1, never quits.'))

    parser.add_argument('--max-age-delta', dest='max_age_delta', type=int,
                        default=DEFAULT_MAX_AGE_DELTA,
                        help='The maximum value in seconds added to max_age')

    args = parser.parse_args()
    set_logger(args.debug, logfile=args.logfile)
    sys.path.insert(0, os.getcwd())  # XXX
    target = resolve_name(args.target)
    if args.params is None:
        params = {}
    else:
        params = decode_params(args.params)

    logger.info('Worker registers at %s' % args.backend)
    logger.info('The heartbeat socket is at %r' % args.heartbeat)
    worker = Worker(target, backend=args.backend, heartbeat=args.heartbeat,
                    params=params, timeout=args.timeout, max_age=args.max_age,
                    max_age_delta=args.max_age_delta)

    try:
        worker.start()
    except KeyboardInterrupt:
        return 1
    finally:
        worker.stop()

    return 0
Ejemplo n.º 5
0
def main(args=sys.argv):

    parser = argparse.ArgumentParser(description="Run some watchers.")

    parser.add_argument("--backend", dest="backend", default=DEFAULT_BACKEND, help="ZMQ socket to the broker.")

    parser.add_argument("--register", dest="register", default=DEFAULT_REG, help="ZMQ socket for the registration.")

    parser.add_argument("target", help="Fully qualified name of the callable.")

    parser.add_argument("--debug", action="store_true", default=False, help="Debug mode")

    parser.add_argument("--logfile", dest="logfile", default="stdout", help="File to log in to.")

    parser.add_argument(
        "--heartbeat", dest="heartbeat", default=DEFAULT_HEARTBEAT, help="ZMQ socket for the heartbeat."
    )

    parser.add_argument("--params", dest="params", default=None, help="The parameters to be used in the worker.")

    parser.add_argument(
        "--timeout",
        dest="timeout",
        type=float,
        default=DEFAULT_TIMEOUT_MOVF,
        help=("The maximum time allowed before the thread " "stacks is dump and the job result not sent " "back."),
    )

    parser.add_argument(
        "--max-age",
        dest="max_age",
        type=float,
        default=DEFAULT_MAX_AGE,
        help=(
            "The maximum age for a worker in seconds. "
            "After that delay, the worker will simply quit. "
            "When set to -1, never quits."
        ),
    )

    parser.add_argument(
        "--max-age-delta",
        dest="max_age_delta",
        type=int,
        default=DEFAULT_MAX_AGE_DELTA,
        help="The maximum value in seconds added to max_age",
    )

    args = parser.parse_args()
    set_logger(args.debug, logfile=args.logfile)
    sys.path.insert(0, os.getcwd())  # XXX
    target = resolve_name(args.target)
    if args.params is None:
        params = {}
    else:
        params = decode_params(args.params)

    logger.info("Worker registers at %s" % args.backend)
    logger.info("The heartbeat socket is at %r" % args.heartbeat)
    worker = Worker(
        target,
        backend=args.backend,
        heartbeat=args.heartbeat,
        register=args.register,
        params=params,
        timeout=args.timeout,
        max_age=args.max_age,
        max_age_delta=args.max_age_delta,
    )

    try:
        worker.start()
    except KeyboardInterrupt:
        return 1
    finally:
        worker.stop()

    return 0