restart-server: Fix restarting server with multiple tornado processes.

Previously, we unconditionally tried to restart the Tornado process
name corresponding to the historically always-true case of a single
Tornado process.  This resulted in Tornado not being automatically
restarted on a production deployment on servers with more than one
Tornado process configured.
This commit is contained in:
Tim Abbott 2018-11-27 17:09:00 -08:00
parent d9e8380981
commit 5a56925495
2 changed files with 23 additions and 2 deletions

View File

@ -5,6 +5,7 @@
# always run from the new version of Zulip, so any bug fixes take
# effect on the very next upgrade.
import argparse
import configparser
import hashlib
import subprocess
import os
@ -45,6 +46,13 @@ args = parser.parse_args()
deploy_path = args.deploy_path
os.chdir(deploy_path)
config_file = configparser.RawConfigParser()
config_file.read("/etc/zulip/zulip.conf")
try:
tornado_processes = int(config_file.get('application_server', 'tornado_processes'))
except (configparser.NoSectionError, configparser.NoOptionError):
tornado_processes = 1
# Handle issues around upstart on Ubuntu Xenial
subprocess.check_call(["./scripts/lib/check-upstart"])
@ -139,7 +147,8 @@ if not args.skip_migrations:
if os.path.exists("/etc/supervisor/conf.d/zulip_db.conf"):
subprocess.check_call(["supervisorctl", "stop", "process-fts-updates"], preexec_fn=su_to_zulip)
core_server_services = ["zulip-django", "zulip-tornado", "zulip-senders:*"]
core_server_services = ["zulip-django", "zulip-senders:*",
"zulip-tornado" if tornado_processes == 1 else "zulip-tornado:*"]
worker_services = ["zulip-workers:*"]
# Stop and start thumbor service only if thumbor is installed.
if os.path.exists("/etc/supervisor/conf.d/thumbor.conf"):

View File

@ -1,4 +1,5 @@
#!/usr/bin/env python3
import configparser
import os
import sys
import pwd
@ -36,12 +37,23 @@ if os.readlink(current_symlink) != deploy_path:
subprocess.check_call(["ln", '-nsf', os.readlink(current_symlink), last_symlink])
subprocess.check_call(["ln", '-nsf', deploy_path, current_symlink])
config_file = configparser.RawConfigParser()
config_file.read("/etc/zulip/zulip.conf")
try:
tornado_processes = int(config_file.get('application_server', 'tornado_processes'))
except (configparser.NoSectionError, configparser.NoOptionError):
tornado_processes = 1
# We restart just the zulip-tornado service early, in order to
# minimize downtime of the tornado service caused by too many Python
# processes restarting at the same time resulting in it receiving
# insufficient priority. This is important, because Tornado is the
# main source of user-visible downtime when we restart a Zulip server.
subprocess.check_call(["supervisorctl", "restart", "zulip-tornado"])
if tornado_processes > 1:
subprocess.check_call(["supervisorctl", "restart", "zulip-tornado:*"])
else:
subprocess.check_call(["supervisorctl", "restart", "zulip-tornado", "zulip-tornado:*"])
# Restart the uWSGI and related processes via supervisorctl.
logging.info("Stopping workers")