From 746c369dd387c10e28b3aa297fe0c3d3780aff55 Mon Sep 17 00:00:00 2001 From: mercma Date: Mon, 19 Nov 2018 09:16:29 -0500 Subject: [PATCH 1/5] Change the 'circusctl options ' command output to be representative of what is in the configuration (ini) file This also removes some of the details that were output that are for internal purposes (e.g. std[out|err|in]_stream dict) example watcher: [watcher:exec] cmd = /usr/bin/python3 args = /root/circus/exec.py stdout_stream.class = FileStream stdout_stream.filename = /root/circus/logger.log close_child_stderr = false close_child_stdout = false close_child_stdin = true use_papa = true old output: error: command b'{"command":"options","properties":{"name":"exec"},"id":"6d93620716dd4555bcbc35181e5ded28"}': Object of type FileStream is not JSON serializable new output: args: /root/circus/exec.py close_child_stderr: False close_child_stdin: True close_child_stdout: False cmd: /usr/bin/python3 copy_env: False env: executable: gid: graceful_timeout: 30.0 max_age: 0 max_age_variance: 30 max_retry: 5 numprocesses: 1 on_demand: False priority: 0 respawn: True send_hup: False shell: False shell_args: singleton: False stdout_stream.class: FileStream stdout_stream.filename: /root/circus/logger.log stop_children: False stop_signal: 15 uid: use_papa: True use_sockets: False warmup_delay: 0 working_dir: /root/circus --- circus/watcher.py | 27 +++++++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/circus/watcher.py b/circus/watcher.py index 7a810f308..4aa3e7e04 100644 --- a/circus/watcher.py +++ b/circus/watcher.py @@ -22,7 +22,7 @@ from circus.papa_process_proxy import PapaProcessProxy from circus import logger from circus import util -from circus.stream import get_stream, Redirector +from circus.stream import get_stream, Redirector, FileStream from circus.stream.papa_redirector import PapaRedirector from circus.util import parse_env_dict, resolve_name, tornado_sleep, IS_WINDOWS from circus.util import papa @@ -1167,11 +1167,34 @@ def do_action(self, num): @util.debuglog def options(self, *args): options = [] + for hook in self.hooks: + hook_name = "hooks.{0}".format(hook) + hook_module = "{0}.{1}".format( + self.hooks[hook].__module__, + self.hooks[hook].__name__) + options.append((hook_name, hook_module)) for name in sorted(self.optnames): + # ignore names stored for internal purposes + if (name in [ + '__name__', + 'stdout_stream_conf', + 'stderr_stream_conf',]): + continue + if name in self._options: options.append((name, self._options[name])) else: - options.append((name, getattr(self, name))) + # some of the options are FileStream class/subclass + # add the 'name' of the class to the options, no the + # class object + if (issubclass(type(getattr(self, name)), FileStream)): + # ignore std[out|err|in]_stream as these are actual class + # objects hoding data + if (name not in ['stdout_stream', 'stderr_stream', + 'stdin_stream']): + options.append((name, getattr(self, name).__class__.__name__)) + else: + options.append((name, getattr(self, name))) return options def is_stopping(self): From 6b7843dca275875bd951b1fab9a6e062f48ef1c9 Mon Sep 17 00:00:00 2001 From: mercma Date: Mon, 19 Nov 2018 12:37:03 -0500 Subject: [PATCH 2/5] Update watcher.py --- circus/watcher.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/circus/watcher.py b/circus/watcher.py index 4aa3e7e04..c057bb3b9 100644 --- a/circus/watcher.py +++ b/circus/watcher.py @@ -1167,6 +1167,9 @@ def do_action(self, num): @util.debuglog def options(self, *args): options = [] + for rlimit in self.rlimits: + rlimit_name = "rlimit_{0}".format(rlimit) + options.append((rlimit_name, self.rlimits[rlimit])) for hook in self.hooks: hook_name = "hooks.{0}".format(hook) hook_module = "{0}.{1}".format( From 509ca10d0e0209b48bf5a8225c36c37d91783b5a Mon Sep 17 00:00:00 2001 From: mercma Date: Mon, 19 Nov 2018 13:25:34 -0500 Subject: [PATCH 3/5] Update watcher.py --- circus/watcher.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/circus/watcher.py b/circus/watcher.py index c057bb3b9..1ace9dcc9 100644 --- a/circus/watcher.py +++ b/circus/watcher.py @@ -22,7 +22,8 @@ from circus.papa_process_proxy import PapaProcessProxy from circus import logger from circus import util -from circus.stream import get_stream, Redirector, FileStream +from circus.stream import get_stream, Redirector +from circus.stream.file_stream import FileStream from circus.stream.papa_redirector import PapaRedirector from circus.util import parse_env_dict, resolve_name, tornado_sleep, IS_WINDOWS from circus.util import papa From a57e4bb7e2ff10017de4d48c8e4deb5c8ec6248d Mon Sep 17 00:00:00 2001 From: mercma Date: Mon, 19 Nov 2018 13:50:13 -0500 Subject: [PATCH 4/5] Update watcher.py --- circus/watcher.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/circus/watcher.py b/circus/watcher.py index 1ace9dcc9..65a2b264b 100644 --- a/circus/watcher.py +++ b/circus/watcher.py @@ -1199,7 +1199,13 @@ def options(self, *args): options.append((name, getattr(self, name).__class__.__name__)) else: options.append((name, getattr(self, name))) - return options + + # for sorting + def getKey(item): + return item[0] + + # return the options sorted by name + return sorted(options, key=getKey) def is_stopping(self): return self._status == 'stopping' From 2018457c27cc4fa9ce75c0d821b9b403bad8e7cd Mon Sep 17 00:00:00 2001 From: mercma Date: Mon, 19 Nov 2018 14:43:34 -0500 Subject: [PATCH 5/5] Update watcher.py --- circus/watcher.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/circus/watcher.py b/circus/watcher.py index 65a2b264b..60117f7b8 100644 --- a/circus/watcher.py +++ b/circus/watcher.py @@ -1168,9 +1168,10 @@ def do_action(self, num): @util.debuglog def options(self, *args): options = [] - for rlimit in self.rlimits: - rlimit_name = "rlimit_{0}".format(rlimit) - options.append((rlimit_name, self.rlimits[rlimit])) + if (self.rlimits): + for rlimit in self.rlimits: + rlimit_name = "rlimit_{0}".format(rlimit) + options.append((rlimit_name, self.rlimits[rlimit])) for hook in self.hooks: hook_name = "hooks.{0}".format(hook) hook_module = "{0}.{1}".format(