From 3717c329b8a7454cd17704b73b6b4be42f3efcb1 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 25 Mar 2022 16:44:26 -0700 Subject: [PATCH] stop-server: Only stop services if they exist and are running. This hides ugly output if the services were already stopped: ``` 2022-03-25 23:26:04,165 upgrade-zulip-stage-2: Stopping Zulip... process-fts-updates: ERROR (not running) zulip-django: ERROR (not running) zulip_deliver_scheduled_emails: ERROR (not running) zulip_deliver_scheduled_messages: ERROR (not running) Zulip stopped successfully! ``` Being able to skip having to shell out to `supervisorctl`, if all services are already stopped is also a significant performance improvement. --- scripts/stop-server | 23 ++++++++++------------- 1 file changed, 10 insertions(+), 13 deletions(-) diff --git a/scripts/stop-server b/scripts/stop-server index 912cf4c761..ee0c1af9e8 100755 --- a/scripts/stop-server +++ b/scripts/stop-server @@ -42,20 +42,17 @@ if has_application_server(): services.append("zulip-tornado:*") services.append("zulip-workers:*") if has_application_server(once=True): - # These used to be included in "zulip-workers:*"; since we may - # be stopping an older version of Zulip, which has not applied - # puppet to reload the new list of processes, only stop them - # if they currently exist according to `supervisorctl`. - services.extend( - list_supervisor_processes( - [ - "zulip_deliver_scheduled_emails", - "zulip_deliver_scheduled_messages", - ] - ), - ) + # These used to be included in "zulip-workers:*"; we may be + # stopping an older version of Zulip, which has not applied + # puppet to reload the new list of processes, but the + # list_supervisor_processes below will filter them out if they + # do not exist. + services.append("zulip_deliver_scheduled_emails") + services.append("zulip_deliver_scheduled_messages") -subprocess.check_call(["supervisorctl", "stop", *services]) +services = list_supervisor_processes(services, only_running=True) +if services: + subprocess.check_call(["supervisorctl", "stop", *services]) print() print(OKGREEN + "Zulip stopped successfully!" + ENDC)