mirror of
https://github.com/zulip/zulip.git
synced 2025-10-25 00:53:56 +00:00
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.
67 lines
2.2 KiB
Python
Executable File
67 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
import logging
|
|
import os
|
|
import pwd
|
|
import subprocess
|
|
import sys
|
|
import time
|
|
|
|
sys.path.append(os.path.join(os.path.dirname(__file__), ".."))
|
|
from scripts.lib.zulip_tools import (
|
|
ENDC,
|
|
OKGREEN,
|
|
WARNING,
|
|
has_application_server,
|
|
has_process_fts_updates,
|
|
list_supervisor_processes,
|
|
)
|
|
|
|
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
|
|
os.chdir(deploy_path)
|
|
|
|
if pwd.getpwuid(os.getuid()).pw_name != "zulip":
|
|
logging.error("Must be run as user 'zulip'.")
|
|
sys.exit(1)
|
|
|
|
logging.Formatter.converter = time.gmtime
|
|
logging.basicConfig(format="%(asctime)s stop-server: %(message)s", level=logging.INFO)
|
|
|
|
services = []
|
|
|
|
# Start with the least-critical services:
|
|
if has_process_fts_updates():
|
|
services.append("process-fts-updates")
|
|
|
|
if has_application_server():
|
|
# Contrary to the order in (re)start-server, we stop django before the
|
|
# workers, to increase the chance that we finish processing any work
|
|
# that may have been enqueued by the Django, leaving the final state
|
|
# closer to "empty." We stop Django before Tornado so it doesn't try
|
|
# to make requests to make queues with a down'd Tornado.
|
|
services.append("zulip-django")
|
|
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])
|
|
|
|
print()
|
|
print(OKGREEN + "Zulip stopped successfully!" + ENDC)
|
|
|
|
using_sso = subprocess.check_output(["./scripts/get-django-setting", "USING_APACHE_SSO"])
|
|
if using_sso.strip() == b"True":
|
|
print()
|
|
print(WARNING + "Apache2 needs to be shut down; as root, run:" + ENDC)
|
|
print(" service apache2 stop")
|
|
print()
|