diff --git a/docker/conf-workers/shared.yaml.j2 b/docker/conf-workers/shared.yaml.j2 index 92d25386dc..fe32f89cf7 100644 --- a/docker/conf-workers/shared.yaml.j2 +++ b/docker/conf-workers/shared.yaml.j2 @@ -2,10 +2,18 @@ # as part of ./Dockerfile-workers. # configure_workers_and_start.py uses and amends to this file depending on the workers # that have been selected. +# Don't bother hand editing this file directly, unless you know what you are doing. Changes +# will not be saved between container rebuilds or image updates. Settings which are +# currently auto-genenerated end up here and override changes made to homeserver.yaml, +# which does not get changed between. +# TLDR: settings in this file override settings in homeserver.yaml. {% if enable_redis %} redis: enabled: true + host: {{ redis_host }} + port: {{ redis_port }} + password: {{ redis_password }} {% endif %} {% if appservice_registrations is not none %} diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index 7ab53f08ce..fbf1c76512 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -663,13 +663,20 @@ def generate_worker_files( workers_in_use = len(worker_types) > 0 + # Override this value here, so it will work as expected in enable_redis below + if workers_in_use is True: + os.environ.["SYNAPSE_ENABLE_REDIS"] = "True" + # Shared homeserver config convert( "/conf/shared.yaml.j2", "/conf/workers/shared.yaml", shared_worker_config=yaml.dump(shared_config), appservice_registrations=appservice_registrations, - enable_redis=workers_in_use, + enable_redis=os.environ.get("SYNAPSE_ENABLE_REDIS", "False"), + redis_host=os.environ.get("SYNAPSE_REDIS_HOST", "localhost"), + redis_port=os.environ.get("SYNAPSE_REDIS_PORT", "6379"), + redis_password=os.environ.get("SYNAPSE_REDIS_PASSWORD", ""), workers_in_use=workers_in_use, ) @@ -798,6 +805,7 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None: getenv_bool("SYNAPSE_SERVE_SERVER_WELLKNOWN", False) ) environ["SYNAPSE_EMAIL"] = str(getenv_bool("SYNAPSE_EMAIL", False)) + environ["SYNAPSE_ENABLE_REDIS"] = str(getenv_bool("SYNAPSE_ENABLE_REDIS", False)) if enable_coturn is True: if "SYNAPSE_TURN_SECRET" not in environ: log("Generating a random secret for SYNAPSE_TURN_SECRET")