Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
scripts: Re-implement list_supervisor_processes using API.
Alex Vandiver7243c3c73d5f
diff --git a/scripts/lib/supervisor.py b/scripts/lib/supervisor.pyindex fda2f0a5ee9..0e37f5d0cf2 100644--- a/scripts/lib/supervisor.py+++ b/scripts/lib/supervisor.py@@ -25,3 +25,29 @@ def rpc() -> client.ServerProxy:return client.ServerProxy("http://localhost", transport=UnixStreamTransport("/var/run/supervisor.sock"))+++def list_supervisor_processes(*filter_names: str) -> List[str]:+ results = []+ processes = rpc().supervisor.getAllProcessInfo()+ assert isinstance(processes, list)+ for process in processes:+ if process["group"] != process["name"]:+ name = f"{process['group']}:{process['name']}"+ else:+ name = process["name"]++ if filter_names:+ match = False+ for filter_name in filter_names:+ if filter_name.endswith(":*") and name.startswith(filter_name[:-1]):+ match = True+ break+ if name == filter_name:+ match = True+ break+ if not match:+ continue++ results.append(name)+ return resultsdiff --git a/scripts/lib/zulip_tools.py b/scripts/lib/zulip_tools.pyindex 838ec3c3dbe..2481cd77a4f 100755--- a/scripts/lib/zulip_tools.py+++ b/scripts/lib/zulip_tools.py@@ -617,25 +617,6 @@ def has_application_server(once: bool = False) -> bool:)-def list_supervisor_processes(*args: str) -> List[str]:- worker_status = subprocess.run(- ["supervisorctl", "status", *args],- text=True,- stdout=subprocess.PIPE,- )- # `supervisorctl 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 pathdiff --git a/scripts/restart-server b/scripts/restart-serverindex 6923988a667..06bbad71651 100755--- a/scripts/restart-server+++ b/scripts/restart-server@@ -8,6 +8,7 @@ import sysimport timesys.path.append(os.path.join(os.path.dirname(__file__), ".."))+from scripts.lib.supervisor import list_supervisor_processesfrom scripts.lib.zulip_tools import (DEPLOYMENTS_DIR,ENDC,@@ -18,7 +19,6 @@ from scripts.lib.zulip_tools import (get_tornado_ports,has_application_server,has_process_fts_updates,- list_supervisor_processes,overwrite_symlink,start_arg_parser,)diff --git a/scripts/stop-server b/scripts/stop-serverindex 03ca9a16404..a1a6ea0af9c 100755--- a/scripts/stop-server+++ b/scripts/stop-server@@ -7,13 +7,13 @@ import sysimport timesys.path.append(os.path.join(os.path.dirname(__file__), ".."))+from scripts.lib.supervisor import list_supervisor_processesfrom scripts.lib.zulip_tools import (ENDC,OKGREEN,WARNING,has_application_server,has_process_fts_updates,- list_supervisor_processes,)deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))