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`.
This commit is contained in:
Alex Vandiver 2021-07-08 18:22:51 -07:00 committed by Tim Abbott
parent 85a9c0982a
commit c94bdd8534
1 changed files with 7 additions and 3 deletions

View File

@ -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():
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