Files
upstream-zulip/scripts/stop-server
upstream-mirror 64898b2c79
Some checks failed
Code scanning / CodeQL (push) Failing after 15s
Zulip production suite / Ubuntu 22.04 production build (push) Failing after 26s
Zulip production suite / Debian 12 production install with custom db name and user (push) Has been skipped
Zulip production suite / Ubuntu 22.04 production install and PostgreSQL upgrade with pgroonga (push) Has been skipped
Zulip production suite / Ubuntu 24.04 production install (push) Has been skipped
Zulip production suite / Ubuntu 26.04 production install (push) Has been skipped
Zulip production suite / Debian 13 production install (push) Has been skipped
Zulip production suite / 7.0 Version Upgrade (push) Has been skipped
Zulip production suite / 8.0 Version Upgrade (push) Has been skipped
Zulip production suite / 6.0 Version Upgrade (push) Has been skipped
Zulip production suite / 10.0 Version Upgrade (push) Has been skipped
Zulip production suite / 9.0 Version Upgrade (push) Has been skipped
Zulip production suite / 12.0 Version Upgrade (push) Has been skipped
Zulip production suite / 11.0 Version Upgrade (push) Has been skipped
GitHub Actions Security Analysis with zizmor / zizmor (push) Failing after 3s
Zulip CI / Debian 12 (Python 3.11, backend + documentation) (push) Failing after 26s
Zulip CI / Ubuntu 22.04 (Python 3.10, backend + frontend) (push) Failing after 3s
Zulip CI / Ubuntu 24.04 (Python 3.12, backend) (push) Failing after 25s
Zulip CI / Ubuntu 26.04 (Python 3.14, backend) (push) Failing after 25s
Zulip CI / Debian 13 (Python 3.13, backend) (push) Failing after 28s
Zulip production suite / Required jobs (push) Has been cancelled
Zulip CI / Required jobs (push) Has been cancelled
API Documentation Update Check / check-feature-level-updated (push) Has been cancelled
API Documentation Update Check / notify-if-api-docs-changed (push) Has been cancelled
snapshot of https://github.com/zulip/zulip.git @ 48c69911c7dd4e03b20552eb3bd77ad8151c1357 (2026-09-15)
2026-09-15 15:05:30 +05:00

84 lines
2.7 KiB
Python
Executable File

#!/usr/bin/env python3
import argparse
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.setup_path import setup_path
setup_path()
from scripts.lib.supervisor import list_supervisor_processes
from scripts.lib.zulip_tools import (
ENDC,
OKGREEN,
WARNING,
has_application_server,
has_process_fts_updates,
su_to_zulip,
)
# Parse arguments before any side effects, so `--help` prints usage
# instead of stopping the server.
argparse.ArgumentParser(
description="Stop the Zulip server (Django, Tornado and workers).",
).parse_args()
deploy_path = os.path.realpath(os.path.join(os.path.dirname(__file__), ".."))
os.chdir(deploy_path)
username = pwd.getpwuid(os.getuid()).pw_name
if username == "root":
su_to_zulip()
elif username != "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.append("zulip-tornado:*")
services.append("zulip-workers:*")
services.append("zulip-tus")
services.append("zulip-katex")
services.append("zulip-email-server")
if has_application_server(once=True):
# 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()
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()