summary refs log tree commit diff
diff options
context:
space:
mode:
authorRichard van der Hoff <richard@matrix.org>2019-06-25 18:09:09 +0100
committerRichard van der Hoff <richard@matrix.org>2019-06-26 15:31:19 +0100
commita5fba9c27c5b27fc3c0b1035e087e46fc11e4d79 (patch)
treef2e6c1d87f084d91b2a26ac6042efec02c0f7f08
parentimprove logging for generate_config_from_template (diff)
downloadsynapse-a5fba9c27c5b27fc3c0b1035e087e46fc11e4d79.tar.xz
Docker: only run --generate-keys when generating config on-the-fly.
We don't want to generate any missing configs when running from a precanned
config.

(There's a strong argument that we don't want to do this at all, since
generating a new signing key on each invocation sounds disasterous, but I don't
fancy unpicking that for now.)
-rwxr-xr-xdocker/start.py28
1 files changed, 21 insertions, 7 deletions
diff --git a/docker/start.py b/docker/start.py
index 9ca139c3ea..59527a5883 100755
--- a/docker/start.py
+++ b/docker/start.py
@@ -101,6 +101,24 @@ def generate_config_from_template(environ, ownership):
     convert("/conf/homeserver.yaml", config_path, environ)
     convert("/conf/log.config", "/compiled/log.config", environ)
     subprocess.check_output(["chown", "-R", ownership, "/data"])
+
+    # Hopefully we already have a signing key, but generate one if not.
+    subprocess.check_output(
+        [
+            "su-exec",
+            ownership,
+            "python",
+            "-m",
+            "synapse.app.homeserver",
+            "--config-path",
+            config_path,
+            # tell synapse to put generated keys in /data rather than /compiled
+            "--keys-directory",
+            "/data",
+            "--generate-keys",
+        ]
+    )
+
     return config_path
 
 
@@ -146,19 +164,15 @@ def main(args, environ):
         config_path = generate_config_from_template(environ, ownership)
 
     args = [
+        "su-exec",
+        ownership,
         "python",
         "-m",
         "synapse.app.homeserver",
         "--config-path",
         config_path,
-        # tell synapse to put any generated keys in /data rather than /compiled
-        "--keys-directory",
-        "/data",
     ]
-
-    # Generate missing keys and start synapse
-    subprocess.check_output(args + ["--generate-keys"])
-    os.execv("/sbin/su-exec", ["su-exec", ownership] + args)
+    os.execv("/sbin/su-exec", args)
 
 
 if __name__ == "__main__":