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

Commit 3b370ec

Browse files
committed
Add a --generate-only option
1 parent ffe6dab commit 3b370ec

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

docker/configure_workers_and_start.py

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
import re
5454
import subprocess
5555
import sys
56+
from argparse import ArgumentParser
5657
from collections import defaultdict
5758
from dataclasses import dataclass, field
5859
from itertools import chain
@@ -968,6 +969,14 @@ def generate_worker_log_config(
968969

969970

970971
def main(args: List[str], environ: MutableMapping[str, str]) -> None:
972+
parser = ArgumentParser()
973+
parser.add_argument(
974+
"--generate-only",
975+
action="store_true",
976+
help="Only generate configuration; don't run Synapse.",
977+
)
978+
opts = parser.parse_args(args)
979+
971980
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
972981
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
973982
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
@@ -1009,6 +1018,10 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
10091018
else:
10101019
log("Worker config exists—not regenerating")
10111020

1021+
if opts.generate_only:
1022+
log("--generate-only: won't run Synapse")
1023+
return
1024+
10121025
# Lifted right out of start.py
10131026
jemallocpath = "/usr/lib/%s-linux-gnu/libjemalloc.so.2" % (platform.machine(),)
10141027

@@ -1031,4 +1044,4 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
10311044

10321045

10331046
if __name__ == "__main__":
1034-
main(sys.argv, os.environ)
1047+
main(sys.argv[1:], os.environ)

0 commit comments

Comments
 (0)