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,20 +42,17 @@ if has_application_server():
services.append("zulip-tornado:*") services.append("zulip-tornado:*")
services.append("zulip-workers:*") services.append("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:*"; we may be
# be stopping an older version of Zulip, which has not applied # stopping an older version of Zulip, which has not applied
# puppet to reload the new list of processes, only stop them # puppet to reload the new list of processes, but the
# if they currently exist according to `supervisorctl`. # list_supervisor_processes below will filter them out if they
services.extend( # do not exist.
list_supervisor_processes( services.append("zulip_deliver_scheduled_emails")
[ services.append("zulip_deliver_scheduled_messages")
"zulip_deliver_scheduled_emails",
"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()
print(OKGREEN + "Zulip stopped successfully!" + ENDC) print(OKGREEN + "Zulip stopped successfully!" + ENDC)