Skip to content

Commit

Permalink
Only log '[num] workers' message when it changes.
Browse files Browse the repository at this point in the history
Otherwise when debug logging is on, the message prints every second even
with no system activity.
  • Loading branch information
rwe committed Jul 19, 2015
1 parent 0d86a90 commit 09357ed
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions gunicorn/arbiter.py
Expand Up @@ -473,6 +473,8 @@ def manage_workers(self):
Maintain the number of workers by spawning or killing
as required.
"""
orig_num_workers = self.num_workers

if len(self.WORKERS.keys()) < self.num_workers:
self.spawn_workers()

Expand All @@ -482,10 +484,11 @@ def manage_workers(self):
(pid, _) = workers.pop(0)
self.kill_worker(pid, signal.SIGTERM)

self.log.debug("{0} workers".format(len(workers)),
extra={"metric": "gunicorn.workers",
"value": len(workers),
"mtype": "gauge"})
if self.num_workers != orig_num_workers:
self.log.debug("{0} workers".format(len(workers)),
extra={"metric": "gunicorn.workers",
"value": len(workers),
"mtype": "gauge"})

def spawn_worker(self):
self.worker_age += 1
Expand Down

0 comments on commit 09357ed

Please sign in to comment.