summary refs log tree commit diff
path: root/synapse
diff options
context:
space:
mode:
authorErik Johnston <erik@matrix.org>2015-03-10 09:39:42 +0000
committerErik Johnston <erik@matrix.org>2015-03-10 09:39:42 +0000
commitb8a6692657d350389f1c3dc8bd903110c2ae1d72 (patch)
tree35d74fd2faf7ce1b740f8a089c471efd4c6f3b37 /synapse
parentMerge branch 'develop' of github.com:matrix-org/synapse into erikj-perf (diff)
downloadsynapse-b8a6692657d350389f1c3dc8bd903110c2ae1d72.tar.xz
Add documentation. When starting via twistd respect soft_file_limit config option.
Diffstat (limited to '')
-rwxr-xr-xsynapse/app/homeserver.py19
1 files changed, 17 insertions, 2 deletions
diff --git a/synapse/app/homeserver.py b/synapse/app/homeserver.py
index dff08c8bc5..26ef02e3de 100755
--- a/synapse/app/homeserver.py
+++ b/synapse/app/homeserver.py
@@ -297,6 +297,15 @@ def change_resource_limit(soft_file_no):
 
 
 def setup(config_options, should_run=True):
+    """
+    Args:
+        config_options_options: The options passed to Synapse. Usually
+            `sys.argv[1:]`.
+        should_run (bool): Whether to start the reactor.
+
+    Returns:
+        HomeServer
+    """
     config = HomeServerConfig.load_config(
         "Synapse Homeserver",
         config_options,
@@ -372,7 +381,7 @@ def setup(config_options, should_run=True):
     hs.get_replication_layer().start_get_pdu_cache()
 
     if not should_run:
-        return
+        return hs
 
     if config.daemonize:
         print config.pid_file
@@ -390,13 +399,19 @@ def setup(config_options, should_run=True):
     else:
         run(config)
 
+    return hs
+
 
 class SynapseService(service.Service):
+    """A twisted Service class that will start synapse. Used to run synapse
+    via twistd and a .tac.
+    """
     def __init__(self, config):
         self.config = config
 
     def startService(self):
-        setup(self.config, should_run=False)
+        hs = setup(self.config, should_run=False)
+        change_resource_limit(hs.config.soft_file_limit)
 
     def stopService(self):
         return self._port.stopListening()