0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-11 12:31:58 +01:00

Include a default configuration file in the 'docs' directory. (#4791)

This commit is contained in:
Richard van der Hoff 2019-03-04 17:14:58 +00:00 committed by GitHub
parent aba5eeabd5
commit 8e28bc5eee
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
11 changed files with 1114 additions and 13 deletions

View file

@ -38,6 +38,14 @@ steps:
- wait
- command:
- "python -m pip install tox"
- "tox -e check-sampleconfig"
label: "\U0001F9F9 check-sample-config"
plugins:
- docker#v3.0.1:
image: "python:3.6"
- command:
- "python -m pip install tox"
- "tox -e py27,codecov"

1
changelog.d/4791.feature Normal file
View file

@ -0,0 +1 @@
Include a default configuration file in the 'docs' directory.

View file

@ -0,0 +1,7 @@
# This file is a reference to the configuration options which can be set in
# homeserver.yaml.
#
# Note that it is not quite ready to be used as-is. If you are starting from
# scratch, it is easier to generate the config files following the instructions
# in INSTALL.md.

1041
docs/sample_config.yaml Normal file

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,18 @@
#!/bin/bash
#
# Update/check the docs/sample_config.yaml
set -e
cd `dirname $0`/..
SAMPLE_CONFIG="docs/sample_config.yaml"
if [ "$1" == "--check" ]; then
diff -u "$SAMPLE_CONFIG" <(./scripts/generate_config --header-file docs/.sample_config_header.yaml) >/dev/null || {
echo -e "\e[1m\e[31m$SAMPLE_CONFIG is not up-to-date. Regenerate it with \`scripts-dev/generate_sample_config\`.\e[0m" >&2
exit 1
}
else
./scripts/generate_config --header-file docs/.sample_config_header.yaml -o "$SAMPLE_CONFIG"
fi

View file

@ -1,6 +1,7 @@
#!/usr/bin/env python
import argparse
import shutil
import sys
from synapse.config.homeserver import HomeServerConfig
@ -50,6 +51,13 @@ if __name__ == "__main__":
help="File to write the configuration to. Default: stdout",
)
parser.add_argument(
"--header-file",
type=argparse.FileType('r'),
help="File from which to read a header, which will be printed before the "
"generated config.",
)
args = parser.parse_args()
report_stats = args.report_stats
@ -64,4 +72,7 @@ if __name__ == "__main__":
report_stats=report_stats,
)
if args.header_file:
shutil.copyfileobj(args.header_file, args.output_file)
args.output_file.write(conf)

View file

@ -180,9 +180,7 @@ class Config(object):
Returns:
str: the yaml config file
"""
default_config = "# vim:ft=yaml\n"
default_config += "\n\n".join(
default_config = "\n\n".join(
dedent(conf)
for conf in self.invoke_all(
"default_config",
@ -297,9 +295,7 @@ class Config(object):
"Must specify a server_name to a generate config for."
" Pass -H server.name."
)
if not cls.path_exists(config_dir_path):
os.makedirs(config_dir_path)
with open(config_path, "w") as config_file:
config_str = obj.generate_config(
config_dir_path=config_dir_path,
data_dir_path=os.getcwd(),
@ -307,9 +303,18 @@ class Config(object):
report_stats=(config_args.report_stats == "yes"),
generate_secrets=True,
)
if not cls.path_exists(config_dir_path):
os.makedirs(config_dir_path)
with open(config_path, "w") as config_file:
config_file.write(
"# vim:ft=yaml\n\n"
)
config_file.write(config_str)
config = yaml.load(config_str)
obj.invoke_all("generate_files", config)
config_file.write(config_str)
print(
(
"A config file has been generated in %r for server name"

View file

@ -49,7 +49,8 @@ class DatabaseConfig(Config):
def default_config(self, data_dir_path, **kwargs):
database_path = os.path.join(data_dir_path, "homeserver.db")
return """\
# Database configuration
## Database ##
database:
# The database engine name
name: "sqlite3"

View file

@ -81,7 +81,9 @@ class LoggingConfig(Config):
def default_config(self, config_dir_path, server_name, **kwargs):
log_config = os.path.join(config_dir_path, server_name + ".log.config")
return """
return """\
## Logging ##
# A yaml python logging config file
#
log_config: "%(log_config)s"

View file

@ -260,9 +260,11 @@ class ServerConfig(Config):
# This is used by remote servers to connect to this server,
# e.g. matrix.org, localhost:8080, etc.
# This is also the last part of your UserID.
#
server_name: "%(server_name)s"
# When running as a daemon, the file to store the pid in
#
pid_file: %(pid_file)s
# CPU affinity mask. Setting this restricts the CPUs on which the
@ -304,9 +306,11 @@ class ServerConfig(Config):
# Set the soft limit on the number of file descriptors synapse can use
# Zero is used to indicate synapse should set the soft limit to the
# hard limit.
#
soft_file_limit: 0
# Set to false to disable presence tracking on this homeserver.
#
use_presence: true
# The GC threshold parameters to pass to `gc.set_threshold`, if defined

View file

@ -118,6 +118,9 @@ commands =
python -m towncrier.check --compare-with=origin/develop
basepython = python3.6
[testenv:check-sampleconfig]
commands = {toxinidir}/scripts-dev/generate_sample_config --check
[testenv:codecov]
skip_install = True
deps =