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.
This commit is contained in:
Alex Vandiver 2022-03-25 16:44:26 -07:00 committed by Tim Abbott
parent 2e5a079ef4
commit 3717c329b8
1 changed files with 10 additions and 13 deletions

View File

@ -42,19 +42,16 @@ 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")
services = list_supervisor_processes(services, only_running=True)
if services:
subprocess.check_call(["supervisorctl", "stop", *services])
print()