mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2024-12-27 01:39:25 -05:00
Remove logger argument and do not catch replication listener
Signed-off-by: Silke <silke@slxh.eu>
This commit is contained in:
parent
ed48ecc58c
commit
26cd3f5690
@ -27,6 +27,8 @@ from synapse.util import PreserveLoggingContext
|
|||||||
from synapse.util.rlimit import change_resource_limit
|
from synapse.util.rlimit import change_resource_limit
|
||||||
from twisted.internet import error, reactor
|
from twisted.internet import error, reactor
|
||||||
|
|
||||||
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
def start_worker_reactor(appname, config):
|
def start_worker_reactor(appname, config):
|
||||||
""" Run the reactor in the main process
|
""" Run the reactor in the main process
|
||||||
@ -122,7 +124,7 @@ def quit_with_error(error_string):
|
|||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
|
|
||||||
def listen_tcp(logger, bind_addresses, port, factory, backlog=50):
|
def listen_tcp(bind_addresses, port, factory, backlog=50):
|
||||||
"""
|
"""
|
||||||
Create a TCP socket for a port and several addresses
|
Create a TCP socket for a port and several addresses
|
||||||
"""
|
"""
|
||||||
@ -135,10 +137,10 @@ def listen_tcp(logger, bind_addresses, port, factory, backlog=50):
|
|||||||
address
|
address
|
||||||
)
|
)
|
||||||
except error.CannotListenError as e:
|
except error.CannotListenError as e:
|
||||||
check_bind_error(logger, e, address, bind_addresses)
|
check_bind_error(e, address, bind_addresses)
|
||||||
|
|
||||||
|
|
||||||
def listen_ssl(logger, bind_addresses, port, factory, context_factory, backlog=50):
|
def listen_ssl(bind_addresses, port, factory, context_factory, backlog=50):
|
||||||
"""
|
"""
|
||||||
Create an SSL socket for a port and several addresses
|
Create an SSL socket for a port and several addresses
|
||||||
"""
|
"""
|
||||||
@ -152,10 +154,10 @@ def listen_ssl(logger, bind_addresses, port, factory, context_factory, backlog=5
|
|||||||
address
|
address
|
||||||
)
|
)
|
||||||
except error.CannotListenError as e:
|
except error.CannotListenError as e:
|
||||||
check_bind_error(logger, e, address, bind_addresses)
|
check_bind_error(e, address, bind_addresses)
|
||||||
|
|
||||||
|
|
||||||
def check_bind_error(logger, e, address, bind_addresses):
|
def check_bind_error(e, address, bind_addresses):
|
||||||
"""
|
"""
|
||||||
This method checks an exception occurred while binding on 0.0.0.0.
|
This method checks an exception occurred while binding on 0.0.0.0.
|
||||||
If :: is specified in the bind addresses a warning is shown.
|
If :: is specified in the bind addresses a warning is shown.
|
||||||
@ -166,7 +168,6 @@ def check_bind_error(logger, e, address, bind_addresses):
|
|||||||
When binding on 0.0.0.0 after :: this can safely be ignored.
|
When binding on 0.0.0.0 after :: this can safely be ignored.
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
logger (Logger): Logger used to log the warning.
|
|
||||||
e (Exception): Exception that was caught.
|
e (Exception): Exception that was caught.
|
||||||
address (str): Address on which binding was attempted.
|
address (str): Address on which binding was attempted.
|
||||||
bind_addresses (list): Addresses on which the service listens.
|
bind_addresses (list): Addresses on which the service listens.
|
||||||
|
@ -25,7 +25,7 @@ from synapse.api.urls import CONTENT_REPO_PREFIX, FEDERATION_PREFIX, \
|
|||||||
LEGACY_MEDIA_PREFIX, MEDIA_PREFIX, SERVER_KEY_PREFIX, SERVER_KEY_V2_PREFIX, \
|
LEGACY_MEDIA_PREFIX, MEDIA_PREFIX, SERVER_KEY_PREFIX, SERVER_KEY_V2_PREFIX, \
|
||||||
STATIC_PREFIX, WEB_CLIENT_PREFIX
|
STATIC_PREFIX, WEB_CLIENT_PREFIX
|
||||||
from synapse.app import _base
|
from synapse.app import _base
|
||||||
from synapse.app._base import quit_with_error
|
from synapse.app._base import quit_with_error, listen_ssl, listen_tcp
|
||||||
from synapse.config._base import ConfigError
|
from synapse.config._base import ConfigError
|
||||||
from synapse.config.homeserver import HomeServerConfig
|
from synapse.config.homeserver import HomeServerConfig
|
||||||
from synapse.crypto import context_factory
|
from synapse.crypto import context_factory
|
||||||
@ -58,7 +58,6 @@ from twisted.internet import defer, reactor
|
|||||||
from twisted.web.resource import EncodingResourceWrapper, Resource
|
from twisted.web.resource import EncodingResourceWrapper, Resource
|
||||||
from twisted.web.server import GzipEncoderFactory
|
from twisted.web.server import GzipEncoderFactory
|
||||||
from twisted.web.static import File
|
from twisted.web.static import File
|
||||||
from twisted.internet import error
|
|
||||||
|
|
||||||
logger = logging.getLogger("synapse.app.homeserver")
|
logger = logging.getLogger("synapse.app.homeserver")
|
||||||
|
|
||||||
@ -131,8 +130,7 @@ class SynapseHomeServer(HomeServer):
|
|||||||
root_resource = create_resource_tree(resources, root_resource)
|
root_resource = create_resource_tree(resources, root_resource)
|
||||||
|
|
||||||
if tls:
|
if tls:
|
||||||
_base.listen_ssl(
|
listen_ssl(
|
||||||
logger,
|
|
||||||
bind_addresses,
|
bind_addresses,
|
||||||
port,
|
port,
|
||||||
SynapseSite(
|
SynapseSite(
|
||||||
@ -145,8 +143,7 @@ class SynapseHomeServer(HomeServer):
|
|||||||
)
|
)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
_base.listen_tcp(
|
listen_tcp(
|
||||||
logger,
|
|
||||||
bind_addresses,
|
bind_addresses,
|
||||||
port,
|
port,
|
||||||
SynapseSite(
|
SynapseSite(
|
||||||
@ -233,8 +230,7 @@ class SynapseHomeServer(HomeServer):
|
|||||||
elif listener["type"] == "manhole":
|
elif listener["type"] == "manhole":
|
||||||
bind_addresses = listener["bind_addresses"]
|
bind_addresses = listener["bind_addresses"]
|
||||||
|
|
||||||
_base.listen_tcp(
|
listen_tcp(
|
||||||
logger,
|
|
||||||
bind_addresses,
|
bind_addresses,
|
||||||
listener["port"],
|
listener["port"],
|
||||||
manhole(
|
manhole(
|
||||||
@ -246,16 +242,13 @@ class SynapseHomeServer(HomeServer):
|
|||||||
elif listener["type"] == "replication":
|
elif listener["type"] == "replication":
|
||||||
bind_addresses = listener["bind_addresses"]
|
bind_addresses = listener["bind_addresses"]
|
||||||
for address in bind_addresses:
|
for address in bind_addresses:
|
||||||
try:
|
factory = ReplicationStreamProtocolFactory(self)
|
||||||
factory = ReplicationStreamProtocolFactory(self)
|
server_listener = reactor.listenTCP(
|
||||||
server_listener = reactor.listenTCP(
|
listener["port"], factory, interface=address
|
||||||
listener["port"], factory, interface=address
|
)
|
||||||
)
|
reactor.addSystemEventTrigger(
|
||||||
reactor.addSystemEventTrigger(
|
"before", "shutdown", server_listener.stopListening,
|
||||||
"before", "shutdown", server_listener.stopListening,
|
)
|
||||||
)
|
|
||||||
except error.CannotListenError as e:
|
|
||||||
_base.check_bind_error(logger, e, address, bind_addresses)
|
|
||||||
else:
|
else:
|
||||||
logger.warn("Unrecognized listener type: %s", listener["type"])
|
logger.warn("Unrecognized listener type: %s", listener["type"])
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user