Skip to content

Commit fa2700f

Browse files
authored
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. <!-- Fixes: # <!-- --> <!-- Supersedes: # <!-- --> <!-- Follows: # <!-- --> <!-- Part of: # <!-- --> Base: `develop` <!-- git-stack-base-branch:develop --> <!-- This pull request is commit-by-commit review friendly. <!-- --> <!-- This pull request is intended for commit-by-commit review. <!-- --> Original commit schedule, with full messages: <ol> <li> Add a --generate-only option </li> </ol> --------- Signed-off-by: Olivier Wilkinson (reivilibre) <[email protected]>
1 parent 8459ac9 commit fa2700f

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

changelog.d/16828.misc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Add a `--generate-only` option to the Complement launcher.

docker/configure_workers_and_start.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@
5858
import re
5959
import subprocess
6060
import sys
61+
from argparse import ArgumentParser
6162
from collections import defaultdict
6263
from itertools import chain
6364
from pathlib import Path
@@ -1024,6 +1025,14 @@ def generate_worker_log_config(
10241025

10251026

10261027
def main(args: List[str], environ: MutableMapping[str, str]) -> None:
1028+
parser = ArgumentParser()
1029+
parser.add_argument(
1030+
"--generate-only",
1031+
action="store_true",
1032+
help="Only generate configuration; don't run Synapse.",
1033+
)
1034+
opts = parser.parse_args(args)
1035+
10271036
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
10281037
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
10291038
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
@@ -1065,6 +1074,10 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
10651074
else:
10661075
log("Worker config exists—not regenerating")
10671076

1077+
if opts.generate_only:
1078+
log("--generate-only: won't run Synapse")
1079+
return
1080+
10681081
# Lifted right out of start.py
10691082
jemallocpath = "/usr/lib/%s-linux-gnu/libjemalloc.so.2" % (platform.machine(),)
10701083

@@ -1087,4 +1100,4 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
10871100

10881101

10891102
if __name__ == "__main__":
1090-
main(sys.argv, os.environ)
1103+
main(sys.argv[1:], os.environ)

0 commit comments

Comments
 (0)