mirror of https://github.com/zulip/zulip.git
tornado: Merge the TORNADO_SERVER and TORNADO_PORTS configs.
Having both of these is confusing; TORNADO_SERVER is used only when there is one TORNADO_PORT. Its primary use is actually to be _unset_, and signal that in-process handling is to be done. Rename to USING_TORNADO, to parallel the existing USING_RABBITMQ, and switch the places that used it for its contents to using TORNADO_PORTS.
This commit is contained in:
parent
4b3121db0b
commit
e5f62d083e
|
@ -62,7 +62,7 @@ def request_event_queue(user_profile: UserProfile, user_client: Client, apply_ma
|
|||
narrow: Iterable[Sequence[str]]=[],
|
||||
bulk_message_deletion: bool=False) -> Optional[str]:
|
||||
|
||||
if not settings.TORNADO_SERVER:
|
||||
if not settings.USING_TORNADO:
|
||||
return None
|
||||
|
||||
tornado_uri = get_tornado_uri(user_profile.realm)
|
||||
|
@ -89,7 +89,7 @@ def request_event_queue(user_profile: UserProfile, user_client: Client, apply_ma
|
|||
return resp.json()['queue_id']
|
||||
|
||||
def get_user_events(user_profile: UserProfile, queue_id: str, last_event_id: int) -> List[Dict[str, Any]]:
|
||||
if not settings.TORNADO_SERVER:
|
||||
if not settings.USING_TORNADO:
|
||||
return []
|
||||
|
||||
tornado_uri = get_tornado_uri(user_profile.realm)
|
||||
|
@ -108,7 +108,7 @@ def get_user_events(user_profile: UserProfile, queue_id: str, last_event_id: int
|
|||
return resp.json()['events']
|
||||
|
||||
def send_notification_http(realm: Realm, data: Mapping[str, Any]) -> None:
|
||||
if not settings.TORNADO_SERVER or settings.RUNNING_INSIDE_TORNADO:
|
||||
if not settings.USING_TORNADO or settings.RUNNING_INSIDE_TORNADO:
|
||||
process_notification(data)
|
||||
else:
|
||||
tornado_uri = get_tornado_uri(realm)
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import json
|
||||
import os
|
||||
from urllib.parse import urlsplit
|
||||
|
||||
from django.conf import settings
|
||||
|
||||
|
@ -12,18 +11,9 @@ if os.path.exists("/etc/zulip/sharding.json"):
|
|||
shard_map = json.loads(f.read())
|
||||
|
||||
def get_tornado_port(realm: Realm) -> int:
|
||||
if settings.TORNADO_SERVER is None:
|
||||
return 9800
|
||||
if settings.TORNADO_PROCESSES == 1:
|
||||
r = urlsplit(settings.TORNADO_SERVER)
|
||||
assert r.port is not None
|
||||
return r.port
|
||||
return shard_map.get(realm.host, 9800)
|
||||
return shard_map.get(realm.host, settings.TORNADO_PORTS[0])
|
||||
|
||||
def get_tornado_uri(realm: Realm) -> str:
|
||||
if settings.TORNADO_PROCESSES == 1:
|
||||
return settings.TORNADO_SERVER
|
||||
|
||||
port = get_tornado_port(realm)
|
||||
return f"http://127.0.0.1:{port}"
|
||||
|
||||
|
|
|
@ -62,7 +62,7 @@ from zerver.models import (
|
|||
get_user_profile_by_id,
|
||||
)
|
||||
|
||||
settings.TORNADO_SERVER = None
|
||||
settings.USING_TORNADO = False
|
||||
# Disable using memcached caches to avoid 'unsupported pickle
|
||||
# protocol' errors if `populate_db` is run with a different Python
|
||||
# from `run-dev.py`.
|
||||
|
|
|
@ -58,6 +58,7 @@ from .configured_settings import (
|
|||
SOCIAL_AUTH_SAML_ENABLED_IDPS,
|
||||
SOCIAL_AUTH_SAML_SECURITY_CONFIG,
|
||||
STATSD_HOST,
|
||||
TORNADO_PORTS,
|
||||
USING_PGROONGA,
|
||||
ZULIP_ADMINISTRATOR,
|
||||
)
|
||||
|
@ -233,7 +234,8 @@ INSTALLED_APPS += EXTRA_INSTALLED_APPS
|
|||
ZILENCER_ENABLED = 'zilencer' in INSTALLED_APPS
|
||||
CORPORATE_ENABLED = 'corporate' in INSTALLED_APPS
|
||||
|
||||
TORNADO_PORTS = get_tornado_ports(config_file)
|
||||
if not TORNADO_PORTS:
|
||||
TORNADO_PORTS = get_tornado_ports(config_file)
|
||||
TORNADO_PROCESSES = len(TORNADO_PORTS)
|
||||
|
||||
RUNNING_INSIDE_TORNADO = False
|
||||
|
|
|
@ -149,10 +149,8 @@ THUMBOR_SERVES_CAMO = False
|
|||
THUMBNAIL_IMAGES = False
|
||||
SENDFILE_BACKEND: Optional[str] = None
|
||||
|
||||
# Base URL of the Tornado server
|
||||
# We set it to None when running backend tests or populate_db.
|
||||
# We override the port number when running frontend tests.
|
||||
TORNADO_SERVER: Optional[str] = 'http://127.0.0.1:9800'
|
||||
TORNADO_PORTS: List[int] = []
|
||||
USING_TORNADO = True
|
||||
|
||||
# ToS/Privacy templates
|
||||
PRIVACY_POLICY: Optional[str] = None
|
||||
|
|
|
@ -69,7 +69,7 @@ EXTRA_INSTALLED_APPS = ["zilencer", "analytics", "corporate"]
|
|||
# Disable Camo in development
|
||||
CAMO_URI = ''
|
||||
|
||||
TORNADO_SERVER = "http://127.0.0.1:9993"
|
||||
TORNADO_PORTS = [9993]
|
||||
|
||||
OPEN_REALM_CREATION = True
|
||||
INVITES_MIN_USER_AGE_DAYS = 0
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import os
|
||||
from typing import Dict, List, Optional, Tuple
|
||||
from typing import Dict, List, Tuple
|
||||
|
||||
import ldap
|
||||
from django_auth_ldap.config import LDAPSearch
|
||||
|
@ -40,12 +40,12 @@ DATABASES["default"] = {
|
|||
"OPTIONS": {"connection_factory": TimeTrackingConnection},
|
||||
}
|
||||
|
||||
# Tests don't use Tornado by default
|
||||
TORNADO_SERVER: Optional[str] = None
|
||||
|
||||
if FULL_STACK_ZULIP_TEST:
|
||||
TORNADO_SERVER = "http://127.0.0.1:9983"
|
||||
TORNADO_PORTS = [9983]
|
||||
else:
|
||||
# Backend tests don't use tornado
|
||||
USING_TORNADO = False
|
||||
CAMO_URI = 'https://external-content.zulipcdn.net/external_content/'
|
||||
CAMO_KEY = 'dummy'
|
||||
|
||||
|
|
Loading…
Reference in New Issue