Skip to content

Commit

Permalink
make sure we dont have duplicate callbacks for circus processes
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekziade committed Jul 6, 2012
1 parent a774209 commit b222616
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions circus/stats/streamer.py
Expand Up @@ -53,16 +53,20 @@ def get_pids(self, watcher=None):
def get_circus_pids(self):
# getting the circusd, circusd-stats and circushttpd pids
res = self.client.send_message('dstats')

pids = {os.getpid(): 'circusd-stats',
res['info']['pid']: 'circusd'}

if 'circushttpd' in self._pids:
pids[self._pids['circushttpd'][0]] = 'circushttpd'
httpd_pids = self.client.send_message('list', name='circushttpd')

if 'pids' in httpd_pids:
httpd_pids = httpd_pids['pids']
if len(httpd_pids) == 1:
pids[httpd_pids[0]] = 'circushttpd'
return pids

def _add_callback(self, name, start=True, kind='watcher'):
logger.debug('Callback added for %s' % name)

if kind == 'watcher':
klass = WatcherStatsCollector
elif kind == 'socket':
Expand All @@ -81,6 +85,10 @@ def _init(self):
res = self.client.send_message('list')

for watcher in res['watchers']:
if watcher in ('circusd', 'circushttpd', 'circusd-stats'):
# this is dealt by the special 'circus' collector
continue

pids = self.client.send_message('list', name=watcher)['pids']
for pid in pids:
self.append_pid(watcher, pid)
Expand Down

0 comments on commit b222616

Please sign in to comment.