예제 #1
0
 def __init__(self, endpoint, pubsub_endoint, stats_endpoint):
     self.topic = 'watcher.'
     self.ctx = zmq.Context()
     self.pubsub_endpoint = pubsub_endoint
     self.sub_socket = self.ctx.socket(zmq.SUB)
     self.sub_socket.setsockopt(zmq.SUBSCRIBE, self.topic)
     self.sub_socket.connect(self.pubsub_endpoint)
     self.loop = ioloop.IOLoop()
     self.substream = zmqstream.ZMQStream(self.sub_socket, self.loop)
     self.substream.on_recv(self.handle_recv)
     self.client = CircusClient(context=self.ctx, endpoint=endpoint)
     self.cmds = get_commands()
     self.watchers = defaultdict(list)
     self._pids = defaultdict(list)
     self.running = False
     self.stopped = False
     self.lock = threading.RLock()
     self.results = Queue.Queue()
     self.stats = StatsCollector(self)
     self.publisher = StatsPublisher(self, stats_endpoint, context=self.ctx)
예제 #2
0
 def __init__(self, endpoint, pubsub_endoint, stats_endpoint, delay=1.):
     self.topic = 'watcher.'
     self.delay = delay
     self.ctx = zmq.Context()
     self.pubsub_endpoint = pubsub_endoint
     self.sub_socket = self.ctx.socket(zmq.SUB)
     self.sub_socket.setsockopt(zmq.SUBSCRIBE, self.topic)
     self.sub_socket.connect(self.pubsub_endpoint)
     self.loop = ioloop.IOLoop()  # events coming from circusd
     self.substream = zmqstream.ZMQStream(self.sub_socket, self.loop)
     self.substream.on_recv(self.handle_recv)
     self.client = CircusClient(context=self.ctx, endpoint=endpoint)
     self.cmds = get_commands()
     self._pids = defaultdict(list)
     self._callbacks = dict()
     self.collector = StatsCollector()
     self.publisher = StatsPublisher(stats_endpoint, self.ctx)
     self.running = False  # should the streamer be running?
     self.stopped = False  # did the collect started yet?
     self.circus_pids = {}