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

Docker: support passing additional commandline args to synapse #8390

Merged
merged 9 commits into from
Oct 11, 2020
1 change: 1 addition & 0 deletions changelog.d/8390.docker
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Added support for passing commandline args to the synapse process. Contributed by @samuel-p.
samuel-p marked this conversation as resolved.
Show resolved Hide resolved
43 changes: 25 additions & 18 deletions docker/start.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,36 +205,43 @@ def main(args, environ):
config_dir, config_path, environ, ownership
)

if mode is not None:
error("Unknown execution mode '%s'" % (mode,))
args = ["python"] + args[1:]
samuel-p marked this conversation as resolved.
Show resolved Hide resolved

config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
if "-m" not in args:
args = ["-m", synapse_worker] + args
samuel-p marked this conversation as resolved.
Show resolved Hide resolved

if not os.path.exists(config_path):
if "SYNAPSE_SERVER_NAME" in environ:
error(
"""\
Config file '%s' does not exist.
if not filter(lambda p: p.startswith("--config-path"), args):
samuel-p marked this conversation as resolved.
Show resolved Hide resolved
samuel-p marked this conversation as resolved.
Show resolved Hide resolved
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
config_path = environ.get(
"SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml"
)

if not os.path.exists(config_path):
if "SYNAPSE_SERVER_NAME" in environ:
error(
"""\
Config file '%s' does not exist.

The synapse docker image no longer supports generating a config file on-the-fly
based on environment variables. You can migrate to a static config file by
running with 'migrate_config'. See the README for more details.
"""
% (config_path,)
)

error(
"Config file '%s' does not exist. You should either create a new "
"config file by running with the `generate` argument (and then edit "
"the resulting file before restarting) or specify the path to an "
"existing config file with the SYNAPSE_CONFIG_PATH variable."
% (config_path,)
)

error(
"Config file '%s' does not exist. You should either create a new "
"config file by running with the `generate` argument (and then edit "
"the resulting file before restarting) or specify the path to an "
"existing config file with the SYNAPSE_CONFIG_PATH variable."
% (config_path,)
)
if "--config-path=" + config_path not in args:
samuel-p marked this conversation as resolved.
Show resolved Hide resolved
args += ["--config-path", config_path]

log("Starting synapse with config file " + config_path)
log("Starting synapse with args " + " ".join(args))

args = ["python", "-m", synapse_worker, "--config-path", config_path]
if ownership is not None:
args = ["gosu", ownership] + args
os.execv("/usr/sbin/gosu", args)
Expand Down