summary refs log tree commit diff
path: root/synapse/server.py
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2019-12-06 17:42:18 +0000
committerErik Johnston <erik@matrix.org>2019-12-10 14:34:17 +0000
commitbc5cb8bfe8c5b0b551de9a97912cd00caeaf6b48 (patch)
treea65e12a7807fbaaf72a0eca2f67efcc9018215c3 /synapse/server.py
parentMerge tag 'v1.7.0rc1' into develop (diff)
downloadsynapse-bc5cb8bfe8c5b0b551de9a97912cd00caeaf6b48.tar.xz
Remove database config parsing from apps.
Diffstat (limited to 'synapse/server.py')
-rw-r--r--synapse/server.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/synapse/server.py b/synapse/server.py
index 2db3dab221..a8b5459ff3 100644
--- a/synapse/server.py
+++ b/synapse/server.py
@@ -97,6 +97,7 @@ from synapse.server_notices.worker_server_notices_sender import (
 )
 from synapse.state import StateHandler, StateResolutionHandler
 from synapse.storage import DataStores, Storage
+from synapse.storage.engines import create_engine
 from synapse.streams.events import EventSources
 from synapse.util import Clock
 from synapse.util.distributor import Distributor
@@ -209,7 +210,7 @@ class HomeServer(object):
     # instantiated during setup() for future return by get_datastore()
     DATASTORE_CLASS = abc.abstractproperty()
 
-    def __init__(self, hostname, reactor=None, **kwargs):
+    def __init__(self, hostname, config, reactor=None, **kwargs):
         """
         Args:
             hostname : The hostname for the server.
@@ -219,6 +220,7 @@ class HomeServer(object):
 
         self._reactor = reactor
         self.hostname = hostname
+        self.config = config
         self._building = {}
         self._listening_services = []
         self.start_time = None
@@ -229,6 +231,12 @@ class HomeServer(object):
         self.admin_redaction_ratelimiter = Ratelimiter()
         self.registration_ratelimiter = Ratelimiter()
 
+        self.database_engine = create_engine(config.database_config)
+        config.database_config.setdefault("args", {})[
+            "cp_openfun"
+        ] = self.database_engine.on_new_connection
+        self.db_config = config.database_config
+
         self.datastores = None
 
         # Other kwargs are explicit dependencies