matrix-synapse: Decouple worker app and config key

This should allow running several separate instances of specalized
workers where that makes sense.
This commit is contained in:
Alexander "Ace" Olofsson 2022-08-29 07:52:25 +02:00
parent 72802cbb79
commit c47961e682
No known key found for this signature in database
GPG key ID: D439C9470CB04C73
4 changed files with 16 additions and 7 deletions

View file

@ -113,23 +113,23 @@ data:
{{- $default := .Values.workers.default }}
{{- range $worker, $config := .Values.workers }}
{{- if $config.enabled }}
{{- if eq $worker "pusher" }}
{{- if or (eq $worker "pusher") (eq $config.app "pusher") }}
# For pusher worker
start_pushers: false
{{- else if eq $worker "appservice" }}
{{- else if or (eq $worker "appservice") (eq $config.app "appservice") }}
# For appservice worker
notify_appservices: false
{{- else if eq $worker "federation_sender" }}
{{- else if or (eq $worker "federation_sender") (eq $config.app "federation_sender") }}
# For federation_sender worker
send_federation: false
{{- else if eq $worker "media_repository" }}
{{- else if or (eq $worker "media_repository") (eq $config.app "media_repository") }}
# For media_repository worker
enable_media_repo: false
{{- else if eq $worker "user_dir" }}
{{- else if or (eq $worker "user_dir") (eq $config.app "user_dir") }}
# For user_dir worker
update_user_directory: false

View file

@ -19,9 +19,10 @@ data:
{{- range $worker, $config := .Values.workers -}}
{{- if $config.enabled -}}
{{- $name := $worker | replace "_" "-" }}
{{- $app := $config.app | default $worker }}
{{ $name }}.worker: |
worker_app: "synapse.app.{{ (not (not $config.generic)) | ternary "generic_worker" $worker }}"
worker_app: "synapse.app.{{ (not (not $config.generic)) | ternary "generic_worker" $app }}"
{{- if $config.name -}}
{{- if (gt ($config.replicaCount | int) 1) -}}
{{- fail "Replica count must be 1 if a worker has a unique name." -}}

View file

@ -3,6 +3,7 @@
{{- range $worker, $config := .Values.workers }}
{{- if $config.enabled }}
{{- $name := $worker | replace "_" "-" }}
{{- $app := $config.app | default $worker }}
---
apiVersion: apps/v1
kind: Deployment
@ -78,7 +79,7 @@ spec:
{{- end }}
{{- end }}
exec python -B -m synapse.app.{{ (not (not $config.generic)) | ternary "generic_worker" $worker }} \
exec python -B -m synapse.app.{{ (not (not $config.generic)) | ternary "generic_worker" $app }} \
-c /synapse/config/homeserver.yaml \
-c /synapse/config/conf.d/ \
-c /synapse/config/{{ $name }}.worker

View file

@ -529,6 +529,13 @@ workers:
federation_sender:
enabled: false
## Specialized workers can also be run as multiple separate instances,
## make sure to read the relevant documentation.
##
# federation_sender_other:
# app: federation_sender
# enabled: false
## This worker deals with serving and storing media.
## NB; Running multiple instances will conflict with background jobs.
##