From 16691110a6b103873e307bdd6ede58bde2691d07 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Thu, 8 Jul 2021 18:26:26 -0700 Subject: [PATCH] scripts: Only stop/restart zulip_deliver_scheduled_* processes if known. Running `supervisorctl stop` or `supervisorctl restart` on a process name which is not known is an error: ``` $ supervisorctl stop nonexistent-process nonexistent-process: ERROR (no such process) $ echo $? 1 ``` ef6d0ec5caa3683931bf69b9ea8cad4b392b198e moved zulip_deliver_scheduled_* out of the `workers:` group. Since upgrades run `stop-server` before applying puppet, the list of processes at that time is from the previous version of Zulip, so may not have the new `zulip_deliver_scheduled_*` names -- and the `stop-server` will hence fail. If the upgrade is not applying puppet, it will `restart-server`. At that point, the old names will still be in the configuration, so relying on the current `superisorctl status` is the best gauge of what exists to restart. In short, only ever stop/start/restart the `zulip_deliver_scheduled_*` processes if `supervisorctl status` knows about them already. --- scripts/restart-server | 9 +++++++-- scripts/stop-server | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/scripts/restart-server b/scripts/restart-server index b1065d5981..0e3fa0313a 100755 --- a/scripts/restart-server +++ b/scripts/restart-server @@ -80,11 +80,16 @@ if has_application_server(): workers.extend(list_supervisor_processes("zulip-workers:*")) if has_application_server(once=True): + # These used to be included in "zulip-workers:*"; since we may + # be restarting 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`. workers.extend( - [ + list_supervisor_processes( "zulip_deliver_scheduled_emails", "zulip_deliver_scheduled_messages", - ] + ) ) if has_process_fts_updates(): diff --git a/scripts/stop-server b/scripts/stop-server index 5cf9f7f239..6de4def2dc 100755 --- a/scripts/stop-server +++ b/scripts/stop-server @@ -13,6 +13,7 @@ from scripts.lib.zulip_tools import ( WARNING, has_application_server, has_process_fts_updates, + list_supervisor_processes, ) deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), "..")) @@ -41,11 +42,15 @@ if has_application_server(): services.extend(["zulip-tornado", "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", - ] + ), ) subprocess.check_call(["supervisorctl", "stop", *services])