Skip to content

Commit

Permalink
Stop supervisor hogging a cpu. (#892)
Browse files Browse the repository at this point in the history
Supervisor spends 100% of its time constantly polling the hundreds of
FDs it has open, including checking if random log FDs are writeable.
Despite not having anything to write, supervisor does this in
effectively an infinite loop. By moving the stdout/err redirection to
the command itself, we can avoid using that code at all.
  • Loading branch information
kormat authored Sep 14, 2016
1 parent 012296e commit 416f02d
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions topology/generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -626,20 +626,23 @@ def _common_entry(self, name, cmd_args, elem_dir):
entry = {
'autostart': 'false' if self.mininet else 'false',
'autorestart': 'false',
'redirect_stderr': 'true',
'environment': 'PYTHONPATH=.,ZLOG_CFG="%s"' % zlog,
'stdout_logfile_maxbytes': 0,
'stdout_logfile': "logs/%s.OUT" % name,
'stdout_logfile': "NONE",
'stderr_logfile': "NONE",
'startretries': 0,
'startsecs': 5,
'command': " ".join(['"%s"' % arg for arg in cmd_args]),
'command': self._mk_cmd(name, cmd_args),
}
if name == "dispatcher":
entry['startsecs'] = 1
if self.mininet:
entry['autostart'] = 'true'
return entry

def _mk_cmd(self, name, cmd_args):
return "bash -c 'exec %s &>logs/%s.OUT'" % (
" ".join(['"%s"' % arg for arg in cmd_args]), name)


class ZKConfGenerator(object):
def __init__(self, out_dir, zookeepers):
Expand Down

0 comments on commit 416f02d

Please sign in to comment.