Skip to content
This repository was archived by the owner on Apr 26, 2024. It is now read-only.

Commit 67aae05

Browse files
reivilibreclokep
andauthored
Support registering Application Services when running with workers under Complement. (#12826)
Co-authored-by: Patrick Cloke <[email protected]>
1 parent 444588c commit 67aae05

File tree

4 files changed

+31
-1
lines changed

4 files changed

+31
-1
lines changed

changelog.d/12826.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Support registering Application Services when running with workers under Complement.

docker/complement/conf-workers/start-complement-synapse-workers.sh

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,11 @@ export SYNAPSE_WORKER_TYPES="\
3636
appservice, \
3737
pusher"
3838

39+
# Add Complement's appservice registration directory, if there is one
40+
# (It can be absent when there are no application services in this test!)
41+
if [ -d /complement/appservice ]; then
42+
export SYNAPSE_AS_REGISTRATION_DIR=/complement/appservice
43+
fi
3944

4045
# Generate a TLS key, then generate a certificate by having Complement's CA sign it
4146
# Note that both the key and certificate are in PEM format (not DER).

docker/conf-workers/shared.yaml.j2

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,13 @@
66
redis:
77
enabled: true
88

9-
{{ shared_worker_config }}
9+
{% if appservice_registrations is not none %}
10+
## Application Services ##
11+
# A list of application service config files to use.
12+
app_service_config_files:
13+
{%- for path in appservice_registrations %}
14+
- "{{ path }}"
15+
{%- endfor %}
16+
{%- endif %}
17+
18+
{{ shared_worker_config }}

docker/configure_workers_and_start.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
# * SYNAPSE_REPORT_STATS: Whether to report stats.
2222
# * SYNAPSE_WORKER_TYPES: A comma separated list of worker names as specified in WORKER_CONFIG
2323
# below. Leave empty for no workers, or set to '*' for all possible workers.
24+
# * SYNAPSE_AS_REGISTRATION_DIR: If specified, a directory in which .yaml and .yml files
25+
# will be treated as Application Service registration files.
2426
# * SYNAPSE_TLS_CERT: Path to a TLS certificate in PEM format.
2527
# * SYNAPSE_TLS_KEY: Path to a TLS key. If this and SYNAPSE_TLS_CERT are specified,
2628
# Nginx will be configured to serve TLS on port 8448.
@@ -32,6 +34,7 @@
3234
import os
3335
import subprocess
3436
import sys
37+
from pathlib import Path
3538
from typing import Any, Dict, List, Mapping, MutableMapping, NoReturn, Set
3639

3740
import jinja2
@@ -491,11 +494,23 @@ def generate_worker_files(
491494
master_log_config = generate_worker_log_config(environ, "master", data_dir)
492495
shared_config["log_config"] = master_log_config
493496

497+
# Find application service registrations
498+
appservice_registrations = None
499+
appservice_registration_dir = os.environ.get("SYNAPSE_AS_REGISTRATION_DIR")
500+
if appservice_registration_dir:
501+
# Scan for all YAML files that should be application service registrations.
502+
appservice_registrations = [
503+
str(reg_path.resolve())
504+
for reg_path in Path(appservice_registration_dir).iterdir()
505+
if reg_path.suffix.lower() in (".yaml", ".yml")
506+
]
507+
494508
# Shared homeserver config
495509
convert(
496510
"/conf/shared.yaml.j2",
497511
"/conf/workers/shared.yaml",
498512
shared_worker_config=yaml.dump(shared_config),
513+
appservice_registrations=appservice_registrations,
499514
)
500515

501516
# Nginx config

0 commit comments

Comments
 (0)