From 416f02d2bcf1ab9ad78a8eeb8bc34dde3b99b7fc Mon Sep 17 00:00:00 2001 From: Stephen Shirley Date: Wed, 14 Sep 2016 14:04:32 +0200 Subject: [PATCH] Stop supervisor hogging a cpu. (#892) 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. --- topology/generator.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/topology/generator.py b/topology/generator.py index 59057c08d6..58c6df44c7 100755 --- a/topology/generator.py +++ b/topology/generator.py @@ -626,13 +626,12 @@ 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 @@ -640,6 +639,10 @@ def _common_entry(self, name, cmd_args, elem_dir): 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):