From c94bdd85340004cc0d41958681056067fe21bfbe Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Thu, 8 Jul 2021 18:22:51 -0700 Subject: [PATCH] zulip_tools: Find missing processes/groups in list_supervisor_processes. Nonexistent processes and groups passed to `supervisortctl status` are printed to STDOUT as follows: ``` $ supervisorctl status zulip-django nonexistent-process nonexistent-group:* nonexistent-process: ERROR (no such process) nonexistent-group: ERROR (no such group) zulip-django RUNNING pid 16043, uptime 17:31:31 ``` On supervisor 4 and above, this exits with an exit code of 4; previously, it returned exit code 0. Ubuntu 18.04 has version 3.3.1, and Ubuntu 20.04 has version 4.1.0. Skip any lines with `ERROR (no such ...)`, and accept exit code 4 from `supervisorctl status`. --- scripts/lib/zulip_tools.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index 97db2531d6..a7cb16f3a6 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -634,15 +634,19 @@ def list_supervisor_processes(*args: str) -> List[str]: universal_newlines=True, stdout=subprocess.PIPE, ) - # `supercisorctl status` returns 3 if any are stopped, which is fine here. - if worker_status.returncode not in (0, 3): + # `supercisorctl status` returns 3 if any are stopped, which is + # fine here; and exit code 4 is for no such process, which is + # handled below. + if worker_status.returncode not in (0, 3, 4): worker_status.check_returncode() processes = [] for status_line in worker_status.stdout.splitlines(): - processes.append(status_line.split()[0]) + if not re.search(r"ERROR \(no such (process|group)\)", status_line): + processes.append(status_line.split()[0]) return processes + def has_process_fts_updates() -> bool: return ( # Current path