Skip to content

Commit

Permalink
Add in support for external redis instance.
Browse files Browse the repository at this point in the history
SYNAPSE_ENABLE_REDIS=1 will activate redis usage. If this isn't on, the following values will not be honored.
SYNAPSE_REDIS_HOST set to the ip of your external redis instance, defaults to 'localhost'.
SYNAPSE_REDIS_PORT set to the port number of your redis server, defaults to '6379'.
SYNAPSE_REDIS_PASSWORD set to the password of your redis server, if used. Defaults to an empty string.
  • Loading branch information
realtyem committed Oct 24, 2022
1 parent 3fa92ff commit a252f05
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
8 changes: 8 additions & 0 deletions docker/conf-workers/shared.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -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 %}
Expand Down
10 changes: 9 additions & 1 deletion docker/configure_workers_and_start.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)

Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit a252f05

Please sign in to comment.