mirror of https://github.com/zulip/zulip.git
zulip_tools: Extract out `list_supervisor_processes`.
This commit is contained in:
parent
261df2b4dc
commit
85a9c0982a
|
@ -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:
|
def has_process_fts_updates() -> bool:
|
||||||
return (
|
return (
|
||||||
# Current path
|
# Current path
|
||||||
|
|
|
@ -18,6 +18,7 @@ from scripts.lib.zulip_tools import (
|
||||||
get_tornado_ports,
|
get_tornado_ports,
|
||||||
has_application_server,
|
has_application_server,
|
||||||
has_process_fts_updates,
|
has_process_fts_updates,
|
||||||
|
list_supervisor_processes,
|
||||||
overwrite_symlink,
|
overwrite_symlink,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -76,15 +77,7 @@ if has_application_server():
|
||||||
if action == "start" or args.less_graceful:
|
if action == "start" or args.less_graceful:
|
||||||
workers.append("zulip-workers:*")
|
workers.append("zulip-workers:*")
|
||||||
else:
|
else:
|
||||||
worker_status = subprocess.run(
|
workers.extend(list_supervisor_processes("zulip-workers:*"))
|
||||||
["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())
|
|
||||||
|
|
||||||
if has_application_server(once=True):
|
if has_application_server(once=True):
|
||||||
workers.extend(
|
workers.extend(
|
||||||
|
|
Loading…
Reference in New Issue