mirror of
https://github.com/element-hq/synapse.git
synced 2024-12-18 17:10:43 +03:00
Actuall set cache factors in workers
This commit is contained in:
parent
78c5eca141
commit
22245fb8a7
1 changed files with 15 additions and 5 deletions
|
@ -108,7 +108,7 @@ def stop(pidfile, app):
|
||||||
|
|
||||||
|
|
||||||
Worker = collections.namedtuple("Worker", [
|
Worker = collections.namedtuple("Worker", [
|
||||||
"app", "configfile", "pidfile", "cache_factor"
|
"app", "configfile", "pidfile", "cache_factor", "cache_factors",
|
||||||
])
|
])
|
||||||
|
|
||||||
|
|
||||||
|
@ -215,6 +215,10 @@ def main():
|
||||||
or pidfile
|
or pidfile
|
||||||
)
|
)
|
||||||
worker_cache_factor = worker_config.get("synctl_cache_factor") or cache_factor
|
worker_cache_factor = worker_config.get("synctl_cache_factor") or cache_factor
|
||||||
|
worker_cache_factors = (
|
||||||
|
worker_config.get("synctl_cache_factors")
|
||||||
|
or cache_factors
|
||||||
|
)
|
||||||
daemonize = worker_config.get("daemonize") or config.get("daemonize")
|
daemonize = worker_config.get("daemonize") or config.get("daemonize")
|
||||||
assert daemonize, "Main process must have daemonize set to true"
|
assert daemonize, "Main process must have daemonize set to true"
|
||||||
|
|
||||||
|
@ -230,8 +234,10 @@ def main():
|
||||||
assert worker_daemonize, "In config %r: expected '%s' to be True" % (
|
assert worker_daemonize, "In config %r: expected '%s' to be True" % (
|
||||||
worker_configfile, "worker_daemonize")
|
worker_configfile, "worker_daemonize")
|
||||||
worker_cache_factor = worker_config.get("synctl_cache_factor")
|
worker_cache_factor = worker_config.get("synctl_cache_factor")
|
||||||
|
worker_cache_factors = worker_config.get("synctl_cache_factors", {})
|
||||||
workers.append(Worker(
|
workers.append(Worker(
|
||||||
worker_app, worker_configfile, worker_pidfile, worker_cache_factor,
|
worker_app, worker_configfile, worker_pidfile, worker_cache_factor,
|
||||||
|
worker_cache_factors,
|
||||||
))
|
))
|
||||||
|
|
||||||
action = options.action
|
action = options.action
|
||||||
|
@ -265,15 +271,19 @@ def main():
|
||||||
start(configfile)
|
start(configfile)
|
||||||
|
|
||||||
for worker in workers:
|
for worker in workers:
|
||||||
|
env = os.environ.copy()
|
||||||
|
|
||||||
if worker.cache_factor:
|
if worker.cache_factor:
|
||||||
os.environ["SYNAPSE_CACHE_FACTOR"] = str(worker.cache_factor)
|
os.environ["SYNAPSE_CACHE_FACTOR"] = str(worker.cache_factor)
|
||||||
|
|
||||||
|
for cache_name, factor in worker.cache_factors.iteritems():
|
||||||
|
os.environ["SYNAPSE_CACHE_FACTOR_" + cache_name.upper()] = str(factor)
|
||||||
|
|
||||||
start_worker(worker.app, configfile, worker.configfile)
|
start_worker(worker.app, configfile, worker.configfile)
|
||||||
|
|
||||||
if cache_factor:
|
# Reset env back to the original
|
||||||
os.environ["SYNAPSE_CACHE_FACTOR"] = str(cache_factor)
|
os.environ.clear()
|
||||||
else:
|
os.environ.update(env)
|
||||||
os.environ.pop("SYNAPSE_CACHE_FACTOR", None)
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
|
Loading…
Reference in a new issue