supervisor: Add a filter for only(-not)-running.

This commit is contained in:
Alex Vandiver 2022-01-20 01:17:41 +00:00 committed by Tim Abbott
parent 7243c3c73d
commit 88c3f560ae
3 changed files with 16 additions and 7 deletions

View File

@ -27,7 +27,9 @@ def rpc() -> client.ServerProxy:
) )
def list_supervisor_processes(*filter_names: str) -> List[str]: def list_supervisor_processes(
filter_names: Optional[List[str]] = None, *, only_running: Optional[bool] = None
) -> List[str]:
results = [] results = []
processes = rpc().supervisor.getAllProcessInfo() processes = rpc().supervisor.getAllProcessInfo()
assert isinstance(processes, list) assert isinstance(processes, list)
@ -49,5 +51,8 @@ def list_supervisor_processes(*filter_names: str) -> List[str]:
if not match: if not match:
continue continue
results.append(name) if only_running is None:
results.append(name)
elif only_running == (process["statename"] == "RUNNING"):
results.append(name)
return results return results

View File

@ -71,7 +71,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:
workers.extend(list_supervisor_processes("zulip-workers:*")) workers.extend(list_supervisor_processes(["zulip-workers:*"]))
if has_application_server(once=True): if has_application_server(once=True):
# These used to be included in "zulip-workers:*"; since we may # These used to be included in "zulip-workers:*"; since we may
@ -81,8 +81,10 @@ if has_application_server():
# `supervisorctl`. # `supervisorctl`.
workers.extend( workers.extend(
list_supervisor_processes( list_supervisor_processes(
"zulip_deliver_scheduled_emails", [
"zulip_deliver_scheduled_messages", "zulip_deliver_scheduled_emails",
"zulip_deliver_scheduled_messages",
]
) )
) )

View File

@ -48,8 +48,10 @@ if has_application_server():
# if they currently exist according to `supervisorctl`. # if they currently exist according to `supervisorctl`.
services.extend( services.extend(
list_supervisor_processes( list_supervisor_processes(
"zulip_deliver_scheduled_emails", [
"zulip_deliver_scheduled_messages", "zulip_deliver_scheduled_emails",
"zulip_deliver_scheduled_messages",
]
), ),
) )