forked from MirrorHub/synapse
Add tcp replication listener type and hook it up
This commit is contained in:
parent
e9dd8370b0
commit
3ba2859e0c
|
@ -56,6 +56,7 @@ from synapse.util.logcontext import LoggingContext, PreserveLoggingContext
|
||||||
from synapse.metrics import register_memory_metrics, get_metrics_for
|
from synapse.metrics import register_memory_metrics, get_metrics_for
|
||||||
from synapse.metrics.resource import MetricsResource, METRICS_PREFIX
|
from synapse.metrics.resource import MetricsResource, METRICS_PREFIX
|
||||||
from synapse.replication.resource import ReplicationResource, REPLICATION_PREFIX
|
from synapse.replication.resource import ReplicationResource, REPLICATION_PREFIX
|
||||||
|
from synapse.replication.tcp.resource import ReplicationStreamProtocolFactory
|
||||||
from synapse.federation.transport.server import TransportLayerServer
|
from synapse.federation.transport.server import TransportLayerServer
|
||||||
|
|
||||||
from synapse.util.rlimit import change_resource_limit
|
from synapse.util.rlimit import change_resource_limit
|
||||||
|
@ -222,6 +223,16 @@ class SynapseHomeServer(HomeServer):
|
||||||
),
|
),
|
||||||
interface=address
|
interface=address
|
||||||
)
|
)
|
||||||
|
elif listener["type"] == "replication":
|
||||||
|
bind_addresses = listener["bind_addresses"]
|
||||||
|
for address in bind_addresses:
|
||||||
|
factory = ReplicationStreamProtocolFactory(self)
|
||||||
|
server_listener = reactor.listenTCP(
|
||||||
|
listener["port"], factory, interface=address
|
||||||
|
)
|
||||||
|
reactor.addSystemEventTrigger(
|
||||||
|
"before", "shutdown", server_listener.stopListening,
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
logger.warn("Unrecognized listener type: %s", listener["type"])
|
logger.warn("Unrecognized listener type: %s", listener["type"])
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue