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
```

ef6d0ec5ca 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.
This commit is contained in:
Alex Vandiver 2021-07-08 18:26:26 -07:00 committed by Tim Abbott
parent c94bdd8534
commit 16691110a6
2 changed files with 14 additions and 4 deletions

View File

@ -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():

View File

@ -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])