Add a --generate-only option
This commit is contained in:
parent
fbafde81a1
commit
321d3590fe
|
@ -53,6 +53,7 @@ import platform
|
||||||
import re
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
|
from argparse import ArgumentParser
|
||||||
from collections import defaultdict
|
from collections import defaultdict
|
||||||
from dataclasses import dataclass, field
|
from dataclasses import dataclass, field
|
||||||
from itertools import chain
|
from itertools import chain
|
||||||
|
@ -968,6 +969,14 @@ def generate_worker_log_config(
|
||||||
|
|
||||||
|
|
||||||
def main(args: List[str], environ: MutableMapping[str, str]) -> None:
|
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_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
|
||||||
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
|
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
|
||||||
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
|
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
|
||||||
|
@ -1009,6 +1018,10 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
|
||||||
else:
|
else:
|
||||||
log("Worker config exists—not regenerating")
|
log("Worker config exists—not regenerating")
|
||||||
|
|
||||||
|
if opts.generate_only:
|
||||||
|
log("--generate-only: won't run Synapse")
|
||||||
|
return
|
||||||
|
|
||||||
# Lifted right out of start.py
|
# Lifted right out of start.py
|
||||||
jemallocpath = "/usr/lib/%s-linux-gnu/libjemalloc.so.2" % (platform.machine(),)
|
jemallocpath = "/usr/lib/%s-linux-gnu/libjemalloc.so.2" % (platform.machine(),)
|
||||||
|
|
||||||
|
@ -1031,4 +1044,4 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main(sys.argv, os.environ)
|
main(sys.argv[1:], os.environ)
|
||||||
|
|
Loading…
Reference in New Issue