2020-06-11 00:54:34 +02:00
|
|
|
import json
|
|
|
|
import os
|
|
|
|
|
2018-11-02 23:51:05 +01:00
|
|
|
from django.conf import settings
|
|
|
|
|
|
|
|
from zerver.models import Realm
|
2020-06-11 00:54:34 +02:00
|
|
|
|
2018-11-07 02:13:37 +01:00
|
|
|
shard_map = {}
|
|
|
|
if os.path.exists("/etc/zulip/sharding.json"):
|
|
|
|
with open("/etc/zulip/sharding.json") as f:
|
|
|
|
shard_map = json.loads(f.read())
|
2018-11-02 23:51:05 +01:00
|
|
|
|
|
|
|
def get_tornado_port(realm: Realm) -> int:
|
2020-09-17 00:30:45 +02:00
|
|
|
return shard_map.get(realm.host, settings.TORNADO_PORTS[0])
|
2018-11-02 23:51:05 +01:00
|
|
|
|
|
|
|
def get_tornado_uri(realm: Realm) -> str:
|
|
|
|
port = get_tornado_port(realm)
|
2020-06-13 08:59:37 +02:00
|
|
|
return f"http://127.0.0.1:{port}"
|
2018-11-03 00:06:13 +01:00
|
|
|
|
|
|
|
def notify_tornado_queue_name(port: int) -> str:
|
|
|
|
if settings.TORNADO_PROCESSES == 1:
|
|
|
|
return "notify_tornado"
|
2020-06-13 08:59:37 +02:00
|
|
|
return f"notify_tornado_port_{port}"
|