diff options
author | Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> | 2021-08-12 16:33:08 +0100 |
---|---|---|
committer | Azrenbeth <7782548+Azrenbeth@users.noreply.github.com> | 2021-09-20 16:38:34 +0100 |
commit | c0915ee9987d627ebd2c6e13aac3f734e093ccdd (patch) | |
tree | 0007493ae517d3bbca641864861698ae1fbcf5e5 | |
parent | Require type hints in the handlers module. (#10831) (diff) | |
download | synapse-c0915ee9987d627ebd2c6e13aac3f734e093ccdd.tar.xz |
call compress_largest_rooms every 1 minute
-rw-r--r-- | synapse/app/_base.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/synapse/app/_base.py b/synapse/app/_base.py index d1aa2e7fb5..10f75c4e69 100644 --- a/synapse/app/_base.py +++ b/synapse/app/_base.py @@ -24,6 +24,7 @@ import traceback import warnings from typing import TYPE_CHECKING, Awaitable, Callable, Iterable +import auto_compressor from cryptography.utils import CryptographyDeprecationWarning from typing_extensions import NoReturn @@ -383,6 +384,9 @@ async def start(hs: "HomeServer"): # If we've configured an expiry time for caches, start the background job now. setup_expire_lru_cache_entries(hs) + # Schedule the state compressor to run + setup_state_compressor(hs) + # It is now safe to start your Synapse. hs.start_listening() hs.get_datastore().db_pool.start_profiling() @@ -417,6 +421,32 @@ async def start(hs: "HomeServer"): atexit.register(gc.freeze) +def setup_state_compressor(hs): + """Schedules the state compressor to run regularly""" + db_config = hs.config.get_single_database().config + if db_config["name"] != "psycopg2": + return + + db_args = db_config["args"] + db_url = "postgresql://{username}:{password}@{host}:{port}/{database}".format( + username=db_args["user"], + password=db_args["password"], + host=db_args["host"], + port=db_args["port"], + database=db_args["database"], + ) + + clock = hs.get_clock() + clock.looping_call( + auto_compressor.compress_largest_rooms, + 1 * 60 * 1000, + db_url=db_url, + chunk_size=10, + default_levels="100,50,25", + number_of_rooms=10, + ) + + def setup_sentry(hs): """Enable sentry integration, if enabled in configuration |