diff options
author | Richard van der Hoff <richard@matrix.org> | 2019-06-25 14:23:24 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2019-06-25 15:30:19 +0100 |
commit | 3f24e4dce7d4dfb50f0f8d958f6f4daf2dbdc70c (patch) | |
tree | 77ed864796e976f09d5427665f0e0738bbc7ab7d | |
parent | Factor out a run_generate_config function (diff) | |
download | synapse-3f24e4dce7d4dfb50f0f8d958f6f4daf2dbdc70c.tar.xz |
Add a main() function
-rwxr-xr-x | docker/start.py | 19 |
1 files changed, 11 insertions, 8 deletions
diff --git a/docker/start.py b/docker/start.py index 70942bcbee..df907fe15c 100755 --- a/docker/start.py +++ b/docker/start.py @@ -129,16 +129,15 @@ def run_generate_config(environ): os.execv("/usr/local/bin/python", args) -# Prepare the configuration -mode = sys.argv[1] if len(sys.argv) > 1 else None -ownership = "{}:{}".format(environ.get("UID", 991), environ.get("GID", 991)) +def main(args, environ): + mode = args[1] if len(args) > 1 else None + ownership = "{}:{}".format(environ.get("UID", 991), environ.get("GID", 991)) -# In generate mode, generate a configuration, missing keys, then exit -if mode == "generate": - run_generate_config(environ) + # In generate mode, generate a configuration, missing keys, then exit + if mode == "generate": + return run_generate_config(environ) -# In normal mode, generate missing keys if any, then run synapse -else: + # In normal mode, generate missing keys if any, then run synapse if "SYNAPSE_CONFIG_PATH" in environ: config_path = environ["SYNAPSE_CONFIG_PATH"] else: @@ -158,3 +157,7 @@ else: # Generate missing keys and start synapse subprocess.check_output(args + ["--generate-keys"]) os.execv("/sbin/su-exec", ["su-exec", ownership] + args) + + +if __name__ == "__main__": + main(sys.argv, os.environ) |