Skip to content

Commit

Permalink
Merge branch 'master' into embed-circushttpd
Browse files Browse the repository at this point in the history
  • Loading branch information
tarekziade committed Jul 6, 2012
2 parents be2b0b5 + 6e7b1b3 commit 49d76db
Show file tree
Hide file tree
Showing 8 changed files with 23 additions and 20 deletions.
6 changes: 3 additions & 3 deletions circus/commands/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,10 +55,10 @@ def execute(self, arbiter, props):
if 'name' in props:
watcher = self._get_watcher(arbiter, props['name'])

pids = watcher.get_active_pids()
status = [(p, watcher.processes[p].status) for p in pids]
processes = watcher.get_active_processes()
status = [(p.pid, p.status) for p in processes]
logger.debug('here is the status of the processes %s' % status)
return {"pids": pids}
return {"pids": [p.pid for p in processes]}
else:
watchers = sorted(arbiter._watchers_names)
return {"watchers": [name for name in watchers]}
Expand Down
7 changes: 5 additions & 2 deletions circus/stats/collector.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,14 +92,16 @@ def collect_stats(self):
# RESOLUTION is a value in seconds that will be used
# to determine the poller timeout of the sockets stats collector
#
# The PeriodicCallback calls the poller every ms, and block
# The PeriodicCallback calls the poller every LOOP_RES ms, and block
# for RESOLUTION seconds unless a read ready event occurs in the
# socket.
#
# This timer is used to limit the number of polls done on the
# socket, so the circusd-stats process don't eat all your CPU
# when you have a high-loaded socket.
#
_RESOLUTION = .1
_LOOP_RES = 10


class SocketStatsCollector(BaseStatsCollector):
Expand All @@ -124,7 +126,8 @@ def __init__(self, streamer, name, callback_time=1., io_loop=None):
for sock, address, fd in self.streamer.get_sockets():
self.poller.watch(sock, read=True, write=False)

self._p = ioloop.PeriodicCallback(self._select, 1, io_loop=io_loop)
self._p = ioloop.PeriodicCallback(self._select, _LOOP_RES,
io_loop=io_loop)

def start(self):
# starting the thread or greenlet
Expand Down
8 changes: 4 additions & 4 deletions circus/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,7 @@ def kill_processes(self, sig):
"""Kill all the processes of this watcher.
"""

for process in self.processes.values():
for process in self.get_active_processes():
try:
self.kill_process(process, sig)
except OSError as e:
Expand Down Expand Up @@ -469,7 +469,7 @@ def stop(self):
logger.debug('gracefully stopping processes [%s] for %ss' % (
self.name, self.graceful_timeout))

while self.get_active_pids() and time.time() < limit:
while self.get_active_processes() and time.time() < limit:
self.kill_processes(signal.SIGTERM)
time.sleep(0.1)
self.reap_processes()
Expand All @@ -483,9 +483,9 @@ def stop(self):

logger.info('%s stopped', self.name)

def get_active_pids(self):
def get_active_processes(self):
"""return a list of pids of active processes (not already stopped)"""
return [p.pid for p in self.processes.values()
return [p for p in self.processes.values()
if p.status not in (DEAD_OR_ZOMBIE, UNEXISTING)]

@property
Expand Down
4 changes: 2 additions & 2 deletions circus/web/circus.css
Original file line number Diff line number Diff line change
Expand Up @@ -507,12 +507,12 @@ td.value {

.stat .cpu {
float: left;
width: 50%;
width: 49%;
}

.stat .mem {
float: right;
width: 50%;
width: 49%;
}

.num_process {
Expand Down
2 changes: 1 addition & 1 deletion circus/web/controller.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def get_pids(self, name):
def get_sockets(self, force_reload=False):
if not self.sockets or force_reload:
res = self.client.send_message('listsockets')
self.sockets = [{'fd': s[0], 'host': s[1]} for s in res['sockets']]
self.sockets = res['sockets']
return self.sockets

def get_series(self, name, pid, field, start=0, end=-1):
Expand Down
2 changes: 1 addition & 1 deletion circus/web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@
<span class="metric_label">CPU</span>
<span class="metric_value" id="${watcher}_last_cpu">0 %</span>
</div>
<div style="metrics mem">
<div class="metrics mem">
<span class="metric_label">Mem</span>
<span class="metric_value" id="${watcher}_last_mem">0 %</span>
</div>
Expand Down
2 changes: 1 addition & 1 deletion circus/web/sockets.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<div class="process">
<div>
<span style="display: inline-block; float: left;"
class="label">${socket['host']} (fd: ${socket['fd']})</span>
class="label">${socket['host']}:${socket['port']} (fd: ${socket['fd']})</span>
</div>

<div class="stat">
Expand Down
12 changes: 6 additions & 6 deletions circus/web/watcher.html
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,13 @@

<div class="stat">
<div id="${name}-${pid}" class="graph"></div>
<div style="padding-bottom: 10px;padding-top: 5px;float:left; width: 50%; border-right: 1px solid #D7DBDE;text-align:center;">
<span class="cpu_label">CPU</span>
<span class="cpu_value" id="${name}-${pid}_last_cpu">0.0 %</span>
<div class="metrics cpu">
<span class="metric_label">CPU</span>
<span class="metric_value" id="${name}-${pid}_last_cpu">0.0 %</span>
</div>
<div style="padding-bottom: 10px;padding-top: 5px;float:right; width: 49%; text-align:center;">
<span class="mem_label">Mem</span>
<span class="mem_value" id="${name}-${pid}_last_mem">0.0 %</span>
<div class="metrics mem">
<span class="metric_label">Mem</span>
<span class="metric_value" id="${name}-${pid}_last_mem">0.0 %</span>
</div>
</div>
</div>
Expand Down

0 comments on commit 49d76db

Please sign in to comment.