diff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.py index ee7bf1951f..97db2531d6 100755 --- a/scripts/lib/zulip_tools.py +++ b/scripts/lib/zulip_tools.py @@ -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 diff --git a/scripts/restart-server b/scripts/restart-server index c1b83a8247..b1065d5981 100755 --- a/scripts/restart-server +++ b/scripts/restart-server @@ -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(