summary refs log tree commit diff
path: root/synapse/app
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2016-06-16 17:29:50 +0100
committerMark Haines <mark.haines@matrix.org>2016-06-16 17:29:50 +0100
commita352b68acf473f59012340b7f481f3dfd6544ac6 (patch)
treed519760f3b97d578c741d5062223189157285a99 /synapse/app
parentAccess the event_cache_size directly from the server object. (diff)
downloadsynapse-a352b68acf473f59012340b7f481f3dfd6544ac6.tar.xz
Use worker_ prefixes for worker config, use existing support for multiple config files
Diffstat (limited to '')
-rw-r--r--synapse/app/pusher.py29
-rw-r--r--synapse/app/synchrotron.py29
2 files changed, 24 insertions, 34 deletions
diff --git a/synapse/app/pusher.py b/synapse/app/pusher.py
index 5d4db4f892..9ac26d52c6 100644
--- a/synapse/app/pusher.py
+++ b/synapse/app/pusher.py
@@ -111,7 +111,7 @@ class PusherServer(HomeServer):
 
     def remove_pusher(self, app_id, push_key, user_id):
         http_client = self.get_simple_http_client()
-        replication_url = self.worker_config.replication_url
+        replication_url = self.config.worker_replication_url
         url = replication_url + "/remove_pushers"
         return http_client.post_json_get_json(url, {
             "remove": [{
@@ -165,7 +165,7 @@ class PusherServer(HomeServer):
     def replicate(self):
         http_client = self.get_simple_http_client()
         store = self.get_datastore()
-        replication_url = self.worker_config.replication_url
+        replication_url = self.config.worker_replication_url
         pusher_pool = self.get_pusherpool()
         clock = self.get_clock()
 
@@ -240,11 +240,8 @@ class PusherServer(HomeServer):
                 logger.exception("Error replicating from %r", replication_url)
                 yield sleep(30)
 
-    def get_event_cache_size(self):
-        return self.worker_config.event_cache_size
 
-
-def setup(worker_name, config_options):
+def start(config_options):
     try:
         config = HomeServerConfig.load_config(
             "Synapse pusher", config_options
@@ -253,9 +250,9 @@ def setup(worker_name, config_options):
         sys.stderr.write("\n" + e.message + "\n")
         sys.exit(1)
 
-    worker_config = config.workers[worker_name]
+    assert config.worker_app == "synapse.app.pusher"
 
-    setup_logging(worker_config.log_config, worker_config.log_file)
+    setup_logging(config.worker_log_config, config.worker_log_file)
 
     if config.start_pushers:
         sys.stderr.write(
@@ -275,20 +272,19 @@ def setup(worker_name, config_options):
         config.server_name,
         db_config=config.database_config,
         config=config,
-        worker_config=worker_config,
         version_string=get_version_string("Synapse", synapse),
         database_engine=database_engine,
     )
 
     ps.setup()
-    ps.start_listening(worker_config.listeners)
+    ps.start_listening(config.worker_listeners)
 
     def run():
         with LoggingContext("run"):
             logger.info("Running")
-            change_resource_limit(worker_config.soft_file_limit)
-            if worker_config.gc_thresholds:
-                ps.set_threshold(worker_config.gc_thresholds)
+            change_resource_limit(config.soft_file_limit)
+            if config.gc_thresholds:
+                ps.set_threshold(config.gc_thresholds)
             reactor.run()
 
     def start():
@@ -298,10 +294,10 @@ def setup(worker_name, config_options):
 
     reactor.callWhenRunning(start)
 
-    if worker_config.daemonize:
+    if config.worker_daemonize:
         daemon = Daemonize(
             app="synapse-pusher",
-            pid=worker_config.pid_file,
+            pid=config.worker_pid_file,
             action=run,
             auto_close_fds=False,
             verbose=True,
@@ -314,5 +310,4 @@ def setup(worker_name, config_options):
 
 if __name__ == '__main__':
     with LoggingContext("main"):
-        worker_name = sys.argv[1]
-        ps = setup(worker_name, sys.argv[2:])
+        ps = start(sys.argv[1:])
diff --git a/synapse/app/synchrotron.py b/synapse/app/synchrotron.py
index d10bb2b3f0..160db8637e 100644
--- a/synapse/app/synchrotron.py
+++ b/synapse/app/synchrotron.py
@@ -97,7 +97,7 @@ class SynchrotronPresence(object):
         self.http_client = hs.get_simple_http_client()
         self.store = hs.get_datastore()
         self.user_to_num_current_syncs = {}
-        self.syncing_users_url = hs.worker_config.replication_url + "/syncing_users"
+        self.syncing_users_url = hs.config.worker_replication_url + "/syncing_users"
         self.clock = hs.get_clock()
 
         active_presence = self.store.take_presence_startup_info()
@@ -305,7 +305,7 @@ class SynchrotronServer(HomeServer):
     def replicate(self):
         http_client = self.get_simple_http_client()
         store = self.get_datastore()
-        replication_url = self.worker_config.replication_url
+        replication_url = self.config.worker_replication_url
         clock = self.get_clock()
         notifier = self.get_notifier()
         presence_handler = self.get_presence_handler()
@@ -403,11 +403,8 @@ class SynchrotronServer(HomeServer):
     def build_typing_handler(self):
         return SynchrotronTyping(self)
 
-    def get_event_cache_size(self):
-        return self.worker_config.event_cache_size
 
-
-def start(worker_name, config_options):
+def start(config_options):
     try:
         config = HomeServerConfig.load_config(
             "Synapse synchrotron", config_options
@@ -416,9 +413,9 @@ def start(worker_name, config_options):
         sys.stderr.write("\n" + e.message + "\n")
         sys.exit(1)
 
-    worker_config = config.workers[worker_name]
+    assert config.worker_app == "synapse.app.synchrotron"
 
-    setup_logging(worker_config.log_config, worker_config.log_file)
+    setup_logging(config.worker_log_config, config.worker_log_file)
 
     database_engine = create_engine(config.database_config)
 
@@ -426,21 +423,20 @@ def start(worker_name, config_options):
         config.server_name,
         db_config=config.database_config,
         config=config,
-        worker_config=worker_config,
         version_string=get_version_string("Synapse", synapse),
         database_engine=database_engine,
         application_service_handler=SynchrotronApplicationService(),
     )
 
     ss.setup()
-    ss.start_listening(worker_config.listeners)
+    ss.start_listening(config.worker_listeners)
 
     def run():
         with LoggingContext("run"):
             logger.info("Running")
-            change_resource_limit(worker_config.soft_file_limit)
-            if worker_config.gc_thresholds:
-                ss.set_threshold(worker_config.gc_thresholds)
+            change_resource_limit(config.soft_file_limit)
+            if config.gc_thresholds:
+                ss.set_threshold(config.gc_thresholds)
             reactor.run()
 
     def start():
@@ -449,10 +445,10 @@ def start(worker_name, config_options):
 
     reactor.callWhenRunning(start)
 
-    if worker_config.daemonize:
+    if config.worker_daemonize:
         daemon = Daemonize(
             app="synapse-synchrotron",
-            pid=worker_config.pid_file,
+            pid=config.worker_pid_file,
             action=run,
             auto_close_fds=False,
             verbose=True,
@@ -465,5 +461,4 @@ def start(worker_name, config_options):
 
 if __name__ == '__main__':
     with LoggingContext("main"):
-        worker_name = sys.argv[1]
-        start(worker_name, sys.argv[2:])
+        start(sys.argv[1:])