tornado: Move default production port to 9800.

In development and test, we keep the Tornado port at 9993 and 9983,
respectively; this allows tests to run while a dev instance is
running.

In production, moving to port 9800 consistently removes an odd edge
case, when just one worker is on an entirely different port than if
two workers are used.
This commit is contained in:
Alex Vandiver 2020-09-14 16:35:44 -07:00 committed by Tim Abbott
parent 5c806fbd52
commit f638518722
7 changed files with 17 additions and 14 deletions

View File

@ -7,7 +7,7 @@ upstream tornado<%= port %> {
<% end -%>
<% else -%>
upstream tornado {
server 127.0.0.1:9993;
server 127.0.0.1:9800;
keepalive 10000;
}
<% end -%>

View File

@ -41,7 +41,7 @@ directory=/home/zulip/deployments/current/
numprocs=<%= @tornado_processes %>
<% else -%>
[program:zulip-tornado]
command=env PYTHONUNBUFFERED=1 /home/zulip/deployments/current/manage.py runtornado 127.0.0.1:9993
command=env PYTHONUNBUFFERED=1 /home/zulip/deployments/current/manage.py runtornado 127.0.0.1:9800
priority=200 ; the relative start priority (default 999)
autostart=true ; start at supervisord start (default: true)
autorestart=true ; whether/when to restart (default: unexpected)

View File

@ -483,16 +483,16 @@ class MissedMessageNotificationsTest(ZulipTestCase):
class FileReloadLogicTest(ZulipTestCase):
def test_persistent_queue_filename(self) -> None:
with self.settings(JSON_PERSISTENT_QUEUE_FILENAME_PATTERN="/home/zulip/tornado/event_queues%s.json"):
self.assertEqual(persistent_queue_filename(9993),
self.assertEqual(persistent_queue_filename(9800),
"/home/zulip/tornado/event_queues.json")
self.assertEqual(persistent_queue_filename(9993, last=True),
self.assertEqual(persistent_queue_filename(9800, last=True),
"/home/zulip/tornado/event_queues.json.last")
with self.settings(JSON_PERSISTENT_QUEUE_FILENAME_PATTERN="/home/zulip/tornado/event_queues%s.json",
TORNADO_PROCESSES=4):
self.assertEqual(persistent_queue_filename(9993),
"/home/zulip/tornado/event_queues.9993.json")
self.assertEqual(persistent_queue_filename(9993, last=True),
"/home/zulip/tornado/event_queues.9993.last.json")
self.assertEqual(persistent_queue_filename(9800),
"/home/zulip/tornado/event_queues.9800.json")
self.assertEqual(persistent_queue_filename(9800, last=True),
"/home/zulip/tornado/event_queues.9800.last.json")
class EventQueueTest(ZulipTestCase):
def get_client_descriptor(self) -> ClientDescriptor:

View File

@ -13,7 +13,7 @@ if os.path.exists("/etc/zulip/sharding.json"):
def get_tornado_port(realm: Realm) -> int:
if settings.TORNADO_SERVER is None:
return 9993
return 9800
if settings.TORNADO_PROCESSES == 1:
r = urlsplit(settings.TORNADO_SERVER)
assert r.port is not None

View File

@ -2,7 +2,7 @@ import os
import sys
import time
from copy import deepcopy
from typing import Any, Dict, List, Optional, Tuple, Union
from typing import Any, Dict, List, Tuple, Union
from urllib.parse import urljoin
from django.template.loaders import app_directories
@ -231,11 +231,7 @@ INSTALLED_APPS += EXTRA_INSTALLED_APPS
ZILENCER_ENABLED = 'zilencer' in INSTALLED_APPS
CORPORATE_ENABLED = 'corporate' in INSTALLED_APPS
# 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_PROCESSES = int(get_config('application_server', 'tornado_processes', '1'))
TORNADO_SERVER: Optional[str] = 'http://127.0.0.1:9993'
RUNNING_INSIDE_TORNADO = False
AUTORELOAD = DEBUG

View File

@ -149,6 +149,11 @@ 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'
# ToS/Privacy templates
PRIVACY_POLICY: Optional[str] = None
TERMS_OF_SERVICE: Optional[str] = None

View File

@ -69,6 +69,8 @@ EXTRA_INSTALLED_APPS = ["zilencer", "analytics", "corporate"]
# Disable Camo in development
CAMO_URI = ''
TORNADO_SERVER = "http://127.0.0.1:9993"
OPEN_REALM_CREATION = True
INVITES_MIN_USER_AGE_DAYS = 0