From 169daa31a000a795491a552279a4ba47c7ffa114 Mon Sep 17 00:00:00 2001 From: Alex Vandiver Date: Fri, 2 May 2025 18:52:33 +0000 Subject: [PATCH] settings: Derive RUNNING_INSIDE_TORNADO based on sys.argv. This allows it to be used at application startup time. --- zerver/management/commands/runtornado.py | 1 - zproject/computed_settings.py | 4 +++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/zerver/management/commands/runtornado.py b/zerver/management/commands/runtornado.py index bfac27956c..9be34a98ed 100644 --- a/zerver/management/commands/runtornado.py +++ b/zerver/management/commands/runtornado.py @@ -12,7 +12,6 @@ from typing_extensions import override from zerver.lib.management import ZulipBaseCommand -settings.RUNNING_INSIDE_TORNADO = True if settings.PRODUCTION: settings.SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") diff --git a/zproject/computed_settings.py b/zproject/computed_settings.py index 0ed6790d27..da705c11a9 100644 --- a/zproject/computed_settings.py +++ b/zproject/computed_settings.py @@ -295,7 +295,9 @@ if not TORNADO_PORTS: TORNADO_PORTS = get_tornado_ports(config_file) TORNADO_PROCESSES = len(TORNADO_PORTS) -RUNNING_INSIDE_TORNADO = False +RUNNING_INSIDE_TORNADO = ( + len(sys.argv) > 1 and "manage.py" in sys.argv[0] and sys.argv[1] == "runtornado" +) SILENCED_SYSTEM_CHECKS = [ # auth.W004 checks that the UserProfile field named by USERNAME_FIELD has