本文整理汇总了Python中circus.sockets.CircusSockets.append方法的典型用法代码示例。如果您正苦于以下问题:Python CircusSockets.append方法的具体用法?Python CircusSockets.append怎么用?Python CircusSockets.append使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circus.sockets.CircusSockets
的用法示例。
在下文中一共展示了CircusSockets.append方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: Arbiter
# 需要导入模块: from circus.sockets import CircusSockets [as 别名]
# 或者: from circus.sockets.CircusSockets import append [as 别名]
class Arbiter(object):
"""Class used to control a list of watchers.
Options:
- **watchers** -- a list of Watcher objects
- **endpoint** -- the controller ZMQ endpoint
- **pubsub_endpoint** -- the pubsub endpoint
- **stats_endpoint** -- the stats endpoint. If not provided,
the *circusd-stats* process will not be launched.
- **check_delay** -- the delay between two controller points
(default: 1 s)
- **prereload_fn** -- callable that will be executed on each reload
(default: None)
- **context** -- if provided, the zmq context to reuse.
(default: None)
- **loop**: if provided, a :class:`zmq.eventloop.ioloop.IOLoop` instance
to reuse. (default: None)
- **plugins** -- a list of plugins. Each item is a mapping with:
- **use** -- Fully qualified name that points to the plugin class
- every other value is passed to the plugin in the **config** option
- **sockets** -- a mapping of sockets. Each key is the socket name,
and each value a :class:`CircusSocket` class. (default: None)
- **warmup_delay** -- a delay in seconds between two watchers startup.
(default: 0)
- **httpd** -- If True, a circushttpd process is run (default: False)
- **httpd_host** -- the circushttpd host (default: localhost)
- **httpd_port** -- the circushttpd port (default: 8080)
- **debug** -- if True, adds a lot of debug info in the stdout (default:
False)
- **proc_name** -- the arbiter process name
"""
restart_after_stop = False
def __init__(self, watchers, endpoint, pubsub_endpoint, check_delay=.5,
prereload_fn=None, context=None, loop=None,
stats_endpoint=None, plugins=None, sockets=None,
warmup_delay=0, httpd=False, httpd_host='localhost',
httpd_port=8080, debug=False, ssh_server=None,
proc_name='circusd'):
self.watchers = watchers
self.endpoint = endpoint
self.check_delay = check_delay
self.prereload_fn = prereload_fn
self.pubsub_endpoint = pubsub_endpoint
self.proc_name = proc_name
self.ctrl = self.loop = None
self.socket_event = False
# initialize zmq context
self.context = context or zmq.Context.instance()
self.pid = os.getpid()
self._watchers_names = {}
self.alive = True
self._lock = RLock()
self.debug = debug
if self.debug:
stdout_stream = stderr_stream = {'class': 'StdoutStream'}
else:
stdout_stream = stderr_stream = None
# initializing circusd-stats as a watcher when configured
self.stats_endpoint = stats_endpoint
if self.stats_endpoint is not None:
cmd = "%s -c 'from circus import stats; stats.main()'" % \
sys.executable
cmd += ' --endpoint %s' % self.endpoint
cmd += ' --pubsub %s' % self.pubsub_endpoint
cmd += ' --statspoint %s' % self.stats_endpoint
if ssh_server is not None:
cmd += ' --ssh %s' % ssh_server
if debug:
cmd += ' --log-level DEBUG'
stats_watcher = Watcher('circusd-stats', cmd, use_sockets=True,
singleton=True,
stdout_stream=stdout_stream,
stderr_stream=stderr_stream,
copy_env=True, copy_path=True)
self.watchers.append(stats_watcher)
# adding the httpd
if httpd:
cmd = ("%s -c 'from circusweb import circushttpd; "
"circushttpd.main()'") % sys.executable
cmd += ' --endpoint %s' % self.endpoint
cmd += ' --fd $(circus.sockets.circushttpd)'
if ssh_server is not None:
cmd += ' --ssh %s' % ssh_server
httpd_watcher = Watcher('circushttpd', cmd, use_sockets=True,
singleton=True,
stdout_stream=stdout_stream,
stderr_stream=stderr_stream,
copy_env=True, copy_path=True)
self.watchers.append(httpd_watcher)
httpd_socket = CircusSocket(name='circushttpd', host=httpd_host,
port=httpd_port)
#.........这里部分代码省略.........