summary refs log tree commit diff
path: root/synapse/app
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2017-11-21 13:29:39 +0000
committerRichard van der Hoff <richard@matrix.org>2017-11-22 16:20:27 +0000
commit68ca8641419ee42606192787b92152353f5c112e (patch)
tree6bbaf289bb72c86a5d1002f69934bd6f20e0ad29 /synapse/app
parentBuild MediaRepositoryResource as a homeserver dependency (diff)
downloadsynapse-68ca8641419ee42606192787b92152353f5c112e.tar.xz
Add config option to disable media_repo on main synapse
... to stop us doing the cache cleanup jobs on the master.
Diffstat (limited to 'synapse/app')
-rwxr-xr-xsynapse/app/homeserver.py21
-rw-r--r--synapse/app/media_repository.py7
2 files changed, 20 insertions, 8 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index 4b6164baa2..6b8875afb4 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -194,14 +194,19 @@ class SynapseHomeServer(HomeServer):
             })
 
         if name in ["media", "federation", "client"]:
-            media_repo = self.get_media_repository_resource()
-            resources.update({
-                MEDIA_PREFIX: media_repo,
-                LEGACY_MEDIA_PREFIX: media_repo,
-                CONTENT_REPO_PREFIX: ContentRepoResource(
-                    self, self.config.uploads_path
-                ),
-            })
+            if self.get_config().enable_media_repo:
+                media_repo = self.get_media_repository_resource()
+                resources.update({
+                    MEDIA_PREFIX: media_repo,
+                    LEGACY_MEDIA_PREFIX: media_repo,
+                    CONTENT_REPO_PREFIX: ContentRepoResource(
+                        self, self.config.uploads_path
+                    ),
+                })
+            elif name == "media":
+                raise ConfigError(
+                    "'media' resource conflicts with enable_media_repo=False",
+                )
 
         if name in ["keys", "federation"]:
             resources.update({
diff --git a/synapse/app/media_repository.py b/synapse/app/media_repository.py
index f54beeb15d..c4e5f0965d 100644
--- a/synapse/app/media_repository.py
+++ b/synapse/app/media_repository.py
@@ -150,6 +150,13 @@ def start(config_options):
 
     assert config.worker_app == "synapse.app.media_repository"
 
+    if config.enable_media_repo:
+        _base.quit_with_error(
+            "enable_media_repo must be disabled in the main synapse process\n"
+            "before the media repo can be run in a separate worker.\n"
+            "Please add ``enable_media_repo: false`` to the main config\n"
+        )
+
     setup_logging(config, use_worker_options=True)
 
     events.USE_FROZEN_DICTS = config.use_frozen_dicts