Add documentation. When starting via twistd respect soft_file_limit config option.

This commit is contained in:
Erik Johnston 2015-03-10 09:39:42 +00:00
parent f31e65ca8b
commit b8a6692657
1 changed files with 17 additions and 2 deletions

View File

@ -297,6 +297,15 @@ def change_resource_limit(soft_file_no):
def setup(config_options, should_run=True): 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( config = HomeServerConfig.load_config(
"Synapse Homeserver", "Synapse Homeserver",
config_options, config_options,
@ -372,7 +381,7 @@ def setup(config_options, should_run=True):
hs.get_replication_layer().start_get_pdu_cache() hs.get_replication_layer().start_get_pdu_cache()
if not should_run: if not should_run:
return return hs
if config.daemonize: if config.daemonize:
print config.pid_file print config.pid_file
@ -390,13 +399,19 @@ def setup(config_options, should_run=True):
else: else:
run(config) run(config)
return hs
class SynapseService(service.Service): 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): def __init__(self, config):
self.config = config self.config = config
def startService(self): 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): def stopService(self):
return self._port.stopListening() return self._port.stopListening()