当前位置: 首页>>代码示例>>Python>>正文


Python Arbiter.load_from_config方法代码示例

本文整理汇总了Python中circus.arbiter.Arbiter.load_from_config方法的典型用法代码示例。如果您正苦于以下问题:Python Arbiter.load_from_config方法的具体用法?Python Arbiter.load_from_config怎么用?Python Arbiter.load_from_config使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在circus.arbiter.Arbiter的用法示例。


在下文中一共展示了Arbiter.load_from_config方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _load_base_arbiter

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
 def _load_base_arbiter(self):
     a = Arbiter.load_from_config(_CONF['reload_base'])
     a.evpub_socket = FakeSocket()
     # initialize watchers
     for watcher in a.iter_watchers():
         a._watchers_names[watcher.name.lower()] = watcher
     return a
开发者ID:jsonkey,项目名称:circus,代码行数:9,代码来源:test_reloadconfig.py

示例2: setUp

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
    def setUp(self):
        conf = _CONF['reload_base']
        self.a = Arbiter.load_from_config(conf)
        self.a.evpub_socket = FakeSocket()

        # initialize watchers
        for watcher in self.a.iter_watchers():
            self.a._watchers_names[watcher.name.lower()] = watcher
开发者ID:EnTeQuAk,项目名称:circus,代码行数:10,代码来源:test_reloadconfig.py

示例3: _load_base_arbiter

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
 def _load_base_arbiter(self, name='reload_base'):
     loop = tornado.ioloop.IOLoop().instance()
     a = Arbiter.load_from_config(_CONF[name], loop=loop)
     a.evpub_socket = FakeSocket()
     # initialize watchers
     for watcher in a.iter_watchers():
         a._watchers_names[watcher.name.lower()] = watcher
     return a
开发者ID:amarandon,项目名称:circus,代码行数:10,代码来源:test_reloadconfig.py

示例4: test_plugin_priority

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
 def test_plugin_priority(self):
     arbiter = Arbiter.load_from_config(_CONF['issue680'])
     watchers = arbiter.iter_watchers()
     self.assertEqual(watchers[0].priority, 30)
     self.assertEqual(watchers[0].name, 'plugin:myplugin')
     self.assertEqual(watchers[1].priority, 20)
     self.assertEqual(watchers[1].cmd, 'sleep 20')
     self.assertEqual(watchers[2].priority, 10)
     self.assertEqual(watchers[2].cmd, 'sleep 10')
开发者ID:SEJeff,项目名称:circus,代码行数:11,代码来源:test_config.py

示例5: main

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Run some watchers.')
    parser.add_argument('config', help='configuration file', nargs='?')

    # XXX we should be able to add all these options in the config file as well
    parser.add_argument('--log-level', dest='loglevel',
                        choices=LOG_LEVELS.keys() + [key.upper() for key in
                                                     LOG_LEVELS.keys()],
                        help="log level")
    parser.add_argument('--log-output', dest='logoutput', help=(
        "The location where the logs will be written. The default behavior "
        "is to write to stdout (you can force it by passing '-' to "
        "this option). Takes a filename otherwise."))

    parser.add_argument('--daemon', dest='daemonize', action='store_true',
                        help="Start circusd in the background")
    parser.add_argument('--pidfile', dest='pidfile')
    parser.add_argument('--version', action='store_true', default=False,
                        help='Displays Circus version and exits.')

    args = parser.parse_args()

    if args.version:
        print(__version__)
        sys.exit(0)

    if args.config is None:
        parser.print_usage()
        sys.exit(0)

    if args.daemonize:
        daemonize()

    # basic logging configuration
    logging.basicConfig()

    # From here it can also come from the arbiter configuration
    # load the arbiter from config
    arbiter = Arbiter.load_from_config(args.config)

    pidfile = args.pidfile or arbiter.pidfile or None
    if pidfile:
        pidfile = Pidfile(pidfile)

        try:
            pidfile.create(os.getpid())
        except RuntimeError, e:
            print(str(e))
            sys.exit(1)
开发者ID:strategist922,项目名称:circus,代码行数:51,代码来源:circusd.py

示例6: test_reload

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
    def test_reload(self):
        a = Arbiter.load_from_config(_CONF["reload1"])
        a.initialize()
        self.assertEqual(len(a.watchers), 1)
        a.reload_from_config(_CONF["reload2"])
        self.assertEqual(len(a.watchers), 2)
        a.reload_from_config(_CONF["reload3"])
        self.assertEqual(len(a.watchers), 1)

        a.reload_from_config(_CONF["reload4"])
        self.assertEqual(len(a.watchers), 1)
        self.assertEqual(a.watchers[0].name, "test3")
        self.assertEqual(a.watchers[0].numprocesses, 1)
        w = a.watchers[0]
        a.reload_from_config(_CONF["reload5"])
        self.assertEqual(a.watchers[0].name, "test3")
        self.assertEqual(a.watchers[0].numprocesses, 2)

        # check that just the number of processes is changed and that the watcher it self is not changed
        self.assertEqual(a.watchers[0], w)

        a.evpub_socket.close()
        a.stop()
开发者ID:Jud,项目名称:circus,代码行数:25,代码来源:test_reloadconfig.py

示例7: print

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
            pidfile.create(os.getpid())
        except RuntimeError, e:
            print(str(e))
            sys.exit(1)

    # configure the logger
    loglevel = args.loglevel or arbiter.loglevel or 'info'
    logoutput = args.logoutput or arbiter.logoutput or '-'
    configure_logger(logger, loglevel, logoutput)

    try:
        restart_after_stop = True
        while restart_after_stop:
            while True:
                try:
                    arbiter = Arbiter.load_from_config(args.config)
                    restart_after_stop = arbiter.start()
                except ReloadArbiterException:
                    pass
                else:
                    break
    except KeyboardInterrupt:
        pass
    finally:
        arbiter.stop()
        if pidfile is not None:
            pidfile.unlink()

    sys.exit(0)

开发者ID:strategist922,项目名称:circus,代码行数:31,代码来源:circusd.py

示例8: main

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
def main():
    import zmq
    try:
        zmq_version = [int(part) for part in zmq.__version__.split('.')]
        if len(zmq_version) < 2:
            raise ValueError()
    except (AttributeError, ValueError):
        print('Unknown PyZQM version - aborting...')
        sys.exit(0)

    if zmq_version[0] < 13 or (zmq_version[0] == 13 and zmq_version[1] < 1):
        print('circusd needs PyZMQ >= 13.1.0 to run - aborting...')
        sys.exit(0)

    parser = argparse.ArgumentParser(description='Run some watchers.')
    parser.add_argument('config', help='configuration file', nargs='?')

    # XXX we should be able to add all these options in the config file as well
    parser.add_argument('--log-level', dest='loglevel',
                        choices=list(LOG_LEVELS.keys()) + [
                            key.upper() for key in LOG_LEVELS.keys()],
                        help="log level")
    parser.add_argument('--log-output', dest='logoutput', help=(
        "The location where the logs will be written. The default behavior "
        "is to write to stdout (you can force it by passing '-' to "
        "this option). Takes a filename otherwise."))

    parser.add_argument('--daemon', dest='daemonize', action='store_true',
                        help="Start circusd in the background")
    parser.add_argument('--pidfile', dest='pidfile')
    parser.add_argument('--version', action='store_true', default=False,
                        help='Displays Circus version and exits.')

    args = parser.parse_args()

    if args.version:
        print(__version__)
        sys.exit(0)

    if args.config is None:
        parser.print_usage()
        sys.exit(0)

    if args.daemonize:
        daemonize()

    # This config call is done to avoid any
    #     "no handlers could be found for logger"
    #
    # error while loding the configuration and setting up the arbiter.
    # The real logging configuration is done right after via
    # a configure_logger() call
    logging.basicConfig()

    # From here it can also come from the arbiter configuration
    # load the arbiter from config
    arbiter = Arbiter.load_from_config(args.config)

    # go ahead and set umask early if it is in the config
    if arbiter.umask is not None:
        os.umask(arbiter.umask)

    pidfile = args.pidfile or arbiter.pidfile or None
    if pidfile:
        pidfile = Pidfile(pidfile)

        try:
            pidfile.create(os.getpid())
        except RuntimeError as e:
            print(str(e))
            sys.exit(1)

    # configure the logger
    loglevel = args.loglevel or arbiter.loglevel or 'info'
    logoutput = args.logoutput or arbiter.logoutput or '-'
    configure_logger(logger, loglevel, logoutput)

    # Main loop
    restart = True
    while restart:
        try:
            arbiter = arbiter or Arbiter.load_from_config(args.config)
            future = arbiter.start()
            restart = False
            if check_future_exception_and_log(future) is None:
                restart = arbiter._restarting
        except Exception as e:
            # emergency stop
            arbiter.loop.run_sync(arbiter._emergency_stop)
            raise(e)
        except KeyboardInterrupt:
            pass
        finally:
            arbiter = None
            if pidfile is not None:
                pidfile.unlink()
    sys.exit(0)
开发者ID:SEJeff,项目名称:circus,代码行数:99,代码来源:circusd.py

示例9: main

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
def main():
    parser = argparse.ArgumentParser(description='Run some watchers.')
    parser.add_argument('config', help='configuration file', nargs='?')

    # XXX we should be able to add all these options in the config file as well
    parser.add_argument('--log-level', dest='loglevel',
                        choices=list(LOG_LEVELS.keys()) + [
                            key.upper() for key in LOG_LEVELS.keys()],
                        help="log level")
    parser.add_argument('--log-output', dest='logoutput', help=(
        "The location where the logs will be written. The default behavior "
        "is to write to stdout (you can force it by passing '-' to "
        "this option). Takes a filename otherwise."))

    parser.add_argument('--daemon', dest='daemonize', action='store_true',
                        help="Start circusd in the background")
    parser.add_argument('--pidfile', dest='pidfile')
    parser.add_argument('--version', action='store_true', default=False,
                        help='Displays Circus version and exits.')

    args = parser.parse_args()

    if args.version:
        print(__version__)
        sys.exit(0)

    if args.config is None:
        parser.print_usage()
        sys.exit(0)

    if args.daemonize:
        daemonize()

    # basic logging configuration
    logging.basicConfig()

    # From here it can also come from the arbiter configuration
    # load the arbiter from config
    arbiter = Arbiter.load_from_config(args.config)

    pidfile = args.pidfile or arbiter.pidfile or None
    if pidfile:
        pidfile = Pidfile(pidfile)

        try:
            pidfile.create(os.getpid())
        except RuntimeError as e:
            print(str(e))
            sys.exit(1)

    # configure the logger
    loglevel = args.loglevel or arbiter.loglevel or 'info'
    logoutput = args.logoutput or arbiter.logoutput or '-'
    configure_logger(logger, loglevel, logoutput)

    # configure the main loop
    #ioloop.install()
    #loop = ioloop.IOLoop.instance()
    #cb = functools.partial(manage_restart, loop, arbiter)
    #periodic = tornado.ioloop.PeriodicCallback(cb, 1000, loop)
    #periodic.start()

    # schedule the arbiter start
    #arbiter = Arbiter.load_from_config(args.config, loop=loop)
    #loop.add_future(arbiter.start(), _arbiter_start_cb)

    # Main loop
    restart = True
    while restart:
        try:
            arbiter = Arbiter.load_from_config(args.config)
            future = arbiter.start()
            restart = False
            if check_future_exception_and_log(future) is None:
                restart = arbiter._restarting
        except Exception as e:
            # emergency stop
            arbiter.loop.run_sync(arbiter._emergency_stop)
            raise(e)
        except KeyboardInterrupt:
            pass
        finally:
            if pidfile is not None:
                pidfile.unlink()
    sys.exit(0)
开发者ID:cdugz,项目名称:circus,代码行数:87,代码来源:circusd.py

示例10: main

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
def main():
    import zmq

    try:
        zmq_version = [int(part) for part in zmq.__version__.split(".")]
        if len(zmq_version) < 2:
            raise ValueError()
    except (AttributeError, ValueError):
        print("Unknown PyZQM version - aborting...")
        sys.exit(0)

    if zmq_version[0] < 13 or (zmq_version[0] == 13 and zmq_version[1] < 1):
        print("circusd needs PyZMQ >= 13.1.0 to run - aborting...")
        sys.exit(0)

    parser = argparse.ArgumentParser(description="Run some watchers.")
    parser.add_argument("config", help="configuration file", nargs="?")

    # XXX we should be able to add all these options in the config file as well
    parser.add_argument(
        "--log-level",
        dest="loglevel",
        choices=list(LOG_LEVELS.keys()) + [key.upper() for key in LOG_LEVELS.keys()],
        help="log level",
    )
    parser.add_argument(
        "--log-output",
        dest="logoutput",
        help=(
            "The location where the logs will be written. The default behavior "
            "is to write to stdout (you can force it by passing '-' to "
            "this option). Takes a filename otherwise."
        ),
    )
    parser.add_argument(
        "--logger-config",
        dest="loggerconfig",
        help=(
            "The location where a standard Python logger configuration INI, "
            "JSON or YAML file can be found.  This can be used to override "
            "the default logging configuration for the arbiter."
        ),
    )

    parser.add_argument("--daemon", dest="daemonize", action="store_true", help="Start circusd in the background")
    parser.add_argument("--pidfile", dest="pidfile")
    parser.add_argument("--version", action="store_true", default=False, help="Displays Circus version and exits.")

    args = parser.parse_args()

    if args.version:
        print(__version__)
        sys.exit(0)

    if args.config is None:
        parser.print_usage()
        sys.exit(0)

    if args.daemonize:
        daemonize()

    # From here it can also come from the arbiter configuration
    # load the arbiter from config
    arbiter = Arbiter.load_from_config(args.config)

    # go ahead and set umask early if it is in the config
    if arbiter.umask is not None:
        os.umask(arbiter.umask)

    pidfile = args.pidfile or arbiter.pidfile or None
    if pidfile:
        pidfile = Pidfile(pidfile)

        try:
            pidfile.create(os.getpid())
        except RuntimeError as e:
            print(str(e))
            sys.exit(1)

    # configure the logger
    loglevel = args.loglevel or arbiter.loglevel or "info"
    logoutput = args.logoutput or arbiter.logoutput or "-"
    loggerconfig = args.loggerconfig or arbiter.loggerconfig or None
    configure_logger(logger, loglevel, logoutput, loggerconfig)

    # Main loop
    restart = True
    while restart:
        try:
            arbiter = arbiter or Arbiter.load_from_config(args.config)
            future = arbiter.start()
            restart = False
            if check_future_exception_and_log(future) is None:
                restart = arbiter._restarting
        except Exception as e:
            # emergency stop
            arbiter.loop.run_sync(arbiter._emergency_stop)
            raise (e)
        except KeyboardInterrupt:
            pass
#.........这里部分代码省略.........
开发者ID:jwal,项目名称:circus,代码行数:103,代码来源:circusd.py

示例11: test_find_hook_in_pythonpath

# 需要导入模块: from circus.arbiter import Arbiter [as 别名]
# 或者: from circus.arbiter.Arbiter import load_from_config [as 别名]
 def test_find_hook_in_pythonpath(self):
     arbiter = Arbiter.load_from_config(_CONF['find_hook_in_pythonpath'])
     watcher = arbiter.iter_watchers()[0]
     self.assertEqual(watcher.hooks['before_start'].__doc__,
                      'relative_hook')
     self.assertTrue('before_start' not in watcher.ignore_hook_failure)
开发者ID:aubustou,项目名称:circus,代码行数:8,代码来源:test_config.py


注:本文中的circus.arbiter.Arbiter.load_from_config方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。