From fa2700f001833d3011ac5e6821ed698f82b3ac21 Mon Sep 17 00:00:00 2001 From: reivilibre Date: Mon, 22 Jan 2024 16:00:04 +0000 Subject: [PATCH] Add a `--generate-only` option to the Complement launcher. (#16828) Pulled out of #16803 since the drive-by cleanup was maybe not as drive-by as I had hoped. Base: `develop` Original commit schedule, with full messages:
  1. Add a --generate-only option
--------- Signed-off-by: Olivier Wilkinson (reivilibre) --- changelog.d/16828.misc | 1 + docker/configure_workers_and_start.py | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) create mode 100644 changelog.d/16828.misc diff --git a/changelog.d/16828.misc b/changelog.d/16828.misc new file mode 100644 index 000000000..6425062bb --- /dev/null +++ b/changelog.d/16828.misc @@ -0,0 +1 @@ +Add a `--generate-only` option to the Complement launcher. \ No newline at end of file diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py index dff8f1733..fdaa16cc2 100755 --- a/docker/configure_workers_and_start.py +++ b/docker/configure_workers_and_start.py @@ -58,6 +58,7 @@ import platform import re import subprocess import sys +from argparse import ArgumentParser from collections import defaultdict from itertools import chain from pathlib import Path @@ -1024,6 +1025,14 @@ def generate_worker_log_config( def main(args: List[str], environ: MutableMapping[str, str]) -> None: + parser = ArgumentParser() + parser.add_argument( + "--generate-only", + action="store_true", + help="Only generate configuration; don't run Synapse.", + ) + opts = parser.parse_args(args) + config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data") config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml") data_dir = environ.get("SYNAPSE_DATA_DIR", "/data") @@ -1065,6 +1074,10 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None: else: log("Worker config exists—not regenerating") + if opts.generate_only: + log("--generate-only: won't run Synapse") + return + # Lifted right out of start.py jemallocpath = "/usr/lib/%s-linux-gnu/libjemalloc.so.2" % (platform.machine(),) @@ -1087,4 +1100,4 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None: if __name__ == "__main__": - main(sys.argv, os.environ) + main(sys.argv[1:], os.environ)