diff --git a/docker/configure_workers_and_start.py b/docker/configure_workers_and_start.py
index dff8f1733a..3917d9ae7e 100755
--- a/docker/configure_workers_and_start.py
+++ b/docker/configure_workers_and_start.py
@@ -2,6 +2,7 @@
#
# This file is licensed under the Affero General Public License (AGPL) version 3.
#
+# Copyright 2021 The Matrix.org Foundation C.I.C.
# Copyright (C) 2023 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
@@ -58,6 +59,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 +1026,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 +1075,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 +1101,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)
|