From 6347dc1beddf71411d0615f4e4101b814457a836 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 25 Jun 2019 18:21:32 +0100 Subject: [PATCH 1/3] Add support for SYNAPSE_CONFIG_DIR --- docker/README.md | 2 ++ docker/start.py | 3 +++ 2 files changed, 5 insertions(+) diff --git a/docker/README.md b/docker/README.md index 5c85c538a..a42d1d24b 100644 --- a/docker/README.md +++ b/docker/README.md @@ -186,6 +186,8 @@ The following environment variables are supported in this mode: * `SYNAPSE_REPORT_STATS` (mandatory, `yes` or `no`): whether to enable anonymous statistics reporting. * `SYNAPSE_CONFIG_PATH` (mandatory): path to the file to be generated. +* `SYNAPSE_CONFIG_DIR`: where additional config files (such as the log config + and event signing key) will be stored. Defaults to `/data`. * `SYNAPSE_DATA_DIR`: where the generated config will put persistent data such as the datatase and media store. Defaults to `/data`. * `UID`, `GID`: the user id and group id to use for creating the data diff --git a/docker/start.py b/docker/start.py index ad968b2a6..99107a9d5 100755 --- a/docker/start.py +++ b/docker/start.py @@ -116,6 +116,7 @@ def run_generate_config(environ, ownership): if v not in environ: error("Environment variable '%s' is mandatory in `generate` mode." % (v,)) + config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data") data_dir = environ.get("SYNAPSE_DATA_DIR", "/data") # make sure that synapse has perms to write to the data dir. @@ -131,6 +132,8 @@ def run_generate_config(environ, ownership): environ["SYNAPSE_REPORT_STATS"], "--config-path", environ["SYNAPSE_CONFIG_PATH"], + "--config-directory", + config_dir, "--data-directory", data_dir, "--generate-config", From 28e30c6581b051c13d53d5abc6eab8b6c7d0f96f Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Tue, 25 Jun 2019 18:23:17 +0100 Subject: [PATCH 2/3] Docker: generate our own log config When running under docker, we want to use docker's own logging stuff rather than losing the logs somewhere on the container's filesystem, so let's use log configs that spit logs out to stdout instead. --- docker/start.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docker/start.py b/docker/start.py index 99107a9d5..06b38ec9d 100755 --- a/docker/start.py +++ b/docker/start.py @@ -116,9 +116,16 @@ def run_generate_config(environ, ownership): if v not in environ: error("Environment variable '%s' is mandatory in `generate` mode." % (v,)) + server_name = environ["SYNAPSE_SERVER_NAME"] config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data") data_dir = environ.get("SYNAPSE_DATA_DIR", "/data") + # create a suitable log config from our template + log_config_file = "%s/%s.log.config" % (config_dir, server_name) + if not os.path.exists(log_config_file): + log("Creating log config %s" % (log_config_file,)) + convert("/conf/log.config", log_config_file, environ) + # make sure that synapse has perms to write to the data dir. subprocess.check_output(["chown", ownership, data_dir]) @@ -127,7 +134,7 @@ def run_generate_config(environ, ownership): "-m", "synapse.app.homeserver", "--server-name", - environ["SYNAPSE_SERVER_NAME"], + server_name, "--report-stats", environ["SYNAPSE_REPORT_STATS"], "--config-path", From befa116b3104b3259254f10b1cccad1b18042a72 Mon Sep 17 00:00:00 2001 From: Richard van der Hoff Date: Wed, 26 Jun 2019 15:52:00 +0100 Subject: [PATCH 3/3] changelog --- changelog.d/5565.feature | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelog.d/5565.feature diff --git a/changelog.d/5565.feature b/changelog.d/5565.feature new file mode 100644 index 000000000..4b0665af0 --- /dev/null +++ b/changelog.d/5565.feature @@ -0,0 +1 @@ +Docker: Send synapse logs to the docker logging system, by default.