Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 2e98b78

Browse files
committed
Ensure the proper handlers are loaded during start-up.
1 parent 0d06a87 commit 2e98b78

File tree

3 files changed

+18
-7
lines changed

3 files changed

+18
-7
lines changed

Diff for: synapse/app/homeserver.py

-2
Original file line numberDiff line numberDiff line change
@@ -389,8 +389,6 @@ def setup(config_options):
389389
except UpgradeDatabaseException as e:
390390
quit_with_error("Failed to upgrade database: %s" % (e,))
391391

392-
hs.setup_master()
393-
394392
async def do_acme() -> bool:
395393
"""
396394
Reprovision an ACME certificate, if it's required.

Diff for: synapse/server.py

+17-4
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,17 @@ class HomeServer(metaclass=abc.ABCMeta):
185185
we are listening on to provide HTTP services.
186186
"""
187187

188-
REQUIRED_ON_MASTER_STARTUP = ["user_directory_handler", "stats_handler"]
188+
REQUIRED_ON_BACKGROUND_TASK_STARTUP = [
189+
"account_validity",
190+
"auth",
191+
"deactivate_account",
192+
"device",
193+
"message",
194+
"pagination",
195+
"profile",
196+
"stats",
197+
"user_directory",
198+
]
189199

190200
# This is overridden in derived application classes
191201
# (such as synapse.app.homeserver.SynapseHomeServer) and gives the class to be
@@ -251,14 +261,17 @@ def setup(self) -> None:
251261
self.datastores = Databases(self.DATASTORE_CLASS, self)
252262
logger.info("Finished setting up.")
253263

254-
def setup_master(self) -> None:
264+
if self.config.run_background_tasks:
265+
self.setup_background_tasks()
266+
267+
def setup_background_tasks(self) -> None:
255268
"""
256269
Some handlers have side effects on instantiation (like registering
257270
background updates). This function causes them to be fetched, and
258271
therefore instantiated, to run those side effects.
259272
"""
260-
for i in self.REQUIRED_ON_MASTER_STARTUP:
261-
getattr(self, "get_" + i)()
273+
for i in self.REQUIRED_ON_BACKGROUND_TASK_STARTUP:
274+
getattr(self, "get_" + i + "_handler")()
262275

263276
def get_reactor(self) -> twisted.internet.base.ReactorBase:
264277
"""

Diff for: tests/utils.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ def setup_test_homeserver(
276276

277277
hs.setup()
278278
if homeserverToUse.__name__ == "TestHomeServer":
279-
hs.setup_master()
279+
hs.setup_background_tasks()
280280

281281
if isinstance(db_engine, PostgresEngine):
282282
database = hs.get_datastores().databases[0]

0 commit comments

Comments
 (0)