zulip_tools: Extract out `list_supervisor_processes`.

This commit is contained in:
Alex Vandiver 2021-07-08 18:21:35 -07:00 committed by Tim Abbott
parent 261df2b4dc
commit 85a9c0982a
2 changed files with 17 additions and 9 deletions

View File

@ -628,6 +628,21 @@ def has_application_server(once: bool = False) -> bool:
)
def list_supervisor_processes(*args: str) -> List[str]:
worker_status = subprocess.run(
["supervisorctl", "status", *args],
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):
worker_status.check_returncode()
processes = []
for status_line in worker_status.stdout.splitlines():
processes.append(status_line.split()[0])
return processes
def has_process_fts_updates() -> bool:
return (
# Current path

View File

@ -18,6 +18,7 @@ from scripts.lib.zulip_tools import (
get_tornado_ports,
has_application_server,
has_process_fts_updates,
list_supervisor_processes,
overwrite_symlink,
)
@ -76,15 +77,7 @@ if has_application_server():
if action == "start" or args.less_graceful:
workers.append("zulip-workers:*")
else:
worker_status = subprocess.run(
["supervisorctl", "status", "zulip-workers:*"],
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):
worker_status.check_returncode()
workers.extend(status_line.split()[0] for status_line in worker_status.stdout.splitlines())
workers.extend(list_supervisor_processes("zulip-workers:*"))
if has_application_server(once=True):
workers.extend(