|
51 | 51 | from synapse.api.constants import MAX_PDU_SIZE
|
52 | 52 | from synapse.app import check_bind_error
|
53 | 53 | from synapse.app.phone_stats_home import start_phone_stats_home
|
| 54 | +from synapse.config import ConfigError |
| 55 | +from synapse.config._base import format_config_error |
54 | 56 | from synapse.config.homeserver import HomeServerConfig
|
55 | 57 | from synapse.config.server import ManholeConfig
|
56 | 58 | from synapse.crypto import context_factory
|
@@ -426,6 +428,7 @@ def run_sighup(*args: Any, **kwargs: Any) -> None:
|
426 | 428 | signal.signal(signal.SIGHUP, run_sighup)
|
427 | 429 |
|
428 | 430 | register_sighup(refresh_certificate, hs)
|
| 431 | + register_sighup(reload_cache_config, hs.config) |
429 | 432 |
|
430 | 433 | # Load the certificate from disk.
|
431 | 434 | refresh_certificate(hs)
|
@@ -480,6 +483,22 @@ def run_sighup(*args: Any, **kwargs: Any) -> None:
|
480 | 483 | atexit.register(gc.freeze)
|
481 | 484 |
|
482 | 485 |
|
| 486 | +def reload_cache_config(config: HomeServerConfig) -> None: |
| 487 | + # For mypy's benefit. It can't know that we haven't altered `config` by the time |
| 488 | + # we call this closure. |
| 489 | + assert config is not None |
| 490 | + try: |
| 491 | + # This will call CacheConfig.read_config, which will automatically call |
| 492 | + # CacheConfig.resize_all_caches. |
| 493 | + config.reload_config_section("caches") |
| 494 | + except ConfigError as e: |
| 495 | + logger.warning("Failed to reload cache config") |
| 496 | + for f in format_config_error(e): |
| 497 | + logger.warning(f) |
| 498 | + else: |
| 499 | + logger.debug("New cache config: %s", config.caches.__dict__) |
| 500 | + |
| 501 | + |
483 | 502 | def setup_sentry(hs: "HomeServer") -> None:
|
484 | 503 | """Enable sentry integration, if enabled in configuration"""
|
485 | 504 |
|
|
0 commit comments