summary refs log tree commit diff
diff options
context:
space:
mode:
authorOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-03-01 13:15:20 +0000
committerOlivier Wilkinson (reivilibre) <oliverw@matrix.org>2022-03-11 11:36:47 +0000
commit85774e17bec93b0a7d7b7d06e2c61960c90f9620 (patch)
tree920c8fff91f66d3fdee24e4a29e510f108d46404
parentSTASH (diff)
downloadsynapse-85774e17bec93b0a7d7b7d06e2c61960c90f9620.tar.xz
STASH
-rw-r--r--scripts-dev/workers_setup.py17
1 files changed, 13 insertions, 4 deletions
diff --git a/scripts-dev/workers_setup.py b/scripts-dev/workers_setup.py

index 4ac1af9b52..f21f8d7336 100644 --- a/scripts-dev/workers_setup.py +++ b/scripts-dev/workers_setup.py
@@ -18,6 +18,9 @@ from pathlib import Path from typing import List, Tuple, Iterable from jinja2 import Environment, FileSystemLoader +from signedjson.key import generate_signing_key, write_signing_keys + +from synapse.util.stringutils import random_string DESIRED_WORKERS = ( ("main", 1), @@ -48,7 +51,7 @@ class Worker: ip: str -def worker_num_to_ip(num: int): +def worker_num_to_ip(num: int) -> str: return f"127.0.57.{num}" @@ -70,12 +73,18 @@ def make_workers(workers: Iterable[Tuple[str, int]]) -> List[Worker]: return result -def generate(worker_counts: Tuple[Tuple[str, int], ...], target_path: Path): +def generate(worker_counts: Tuple[Tuple[str, int], ...], target_path: Path) -> None: if target_path.exists(): print("Target path already exists. Won't overwrite.") return target_path.mkdir() + # Generate a signing key + key_id = "a_" + random_string(4) + key = (generate_signing_key(key_id),) + with open(target_path.joinpath("signing.key"), "w") as fout: + write_signing_keys(fout, key) + env = Environment(loader=FileSystemLoader(dirname(__file__) + "/workers_setup")) hs_template = env.get_template("homeserver.yaml.j2") worker_template = env.get_template("worker.yaml.j2") @@ -125,10 +134,10 @@ def generate(worker_counts: Tuple[Tuple[str, int], ...], target_path: Path): fout.write(hs_config) -def main(target_path: Path): +def main(target_path: Path) -> None: generate(DESIRED_WORKERS, target_path) if __name__ == '__main__': target_path = Path(sys.argv[1]) - main(target_path) \ No newline at end of file + main(target_path)