Include a default configuration file in the 'docs' directory. (#4791)
This commit is contained in:
parent
aba5eeabd5
commit
8e28bc5eee
|
@ -38,6 +38,14 @@ steps:
|
||||||
|
|
||||||
- wait
|
- 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:
|
- command:
|
||||||
- "python -m pip install tox"
|
- "python -m pip install tox"
|
||||||
- "tox -e py27,codecov"
|
- "tox -e py27,codecov"
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Include a default configuration file in the 'docs' directory.
|
|
@ -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.
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -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
|
|
@ -1,6 +1,7 @@
|
||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
import argparse
|
import argparse
|
||||||
|
import shutil
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
from synapse.config.homeserver import HomeServerConfig
|
from synapse.config.homeserver import HomeServerConfig
|
||||||
|
@ -50,6 +51,13 @@ if __name__ == "__main__":
|
||||||
help="File to write the configuration to. Default: stdout",
|
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()
|
args = parser.parse_args()
|
||||||
|
|
||||||
report_stats = args.report_stats
|
report_stats = args.report_stats
|
||||||
|
@ -64,4 +72,7 @@ if __name__ == "__main__":
|
||||||
report_stats=report_stats,
|
report_stats=report_stats,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if args.header_file:
|
||||||
|
shutil.copyfileobj(args.header_file, args.output_file)
|
||||||
|
|
||||||
args.output_file.write(conf)
|
args.output_file.write(conf)
|
||||||
|
|
|
@ -180,9 +180,7 @@ class Config(object):
|
||||||
Returns:
|
Returns:
|
||||||
str: the yaml config file
|
str: the yaml config file
|
||||||
"""
|
"""
|
||||||
default_config = "# vim:ft=yaml\n"
|
default_config = "\n\n".join(
|
||||||
|
|
||||||
default_config += "\n\n".join(
|
|
||||||
dedent(conf)
|
dedent(conf)
|
||||||
for conf in self.invoke_all(
|
for conf in self.invoke_all(
|
||||||
"default_config",
|
"default_config",
|
||||||
|
@ -297,19 +295,26 @@ class Config(object):
|
||||||
"Must specify a server_name to a generate config for."
|
"Must specify a server_name to a generate config for."
|
||||||
" Pass -H server.name."
|
" Pass -H server.name."
|
||||||
)
|
)
|
||||||
|
|
||||||
|
config_str = obj.generate_config(
|
||||||
|
config_dir_path=config_dir_path,
|
||||||
|
data_dir_path=os.getcwd(),
|
||||||
|
server_name=server_name,
|
||||||
|
report_stats=(config_args.report_stats == "yes"),
|
||||||
|
generate_secrets=True,
|
||||||
|
)
|
||||||
|
|
||||||
if not cls.path_exists(config_dir_path):
|
if not cls.path_exists(config_dir_path):
|
||||||
os.makedirs(config_dir_path)
|
os.makedirs(config_dir_path)
|
||||||
with open(config_path, "w") as config_file:
|
with open(config_path, "w") as config_file:
|
||||||
config_str = obj.generate_config(
|
config_file.write(
|
||||||
config_dir_path=config_dir_path,
|
"# vim:ft=yaml\n\n"
|
||||||
data_dir_path=os.getcwd(),
|
|
||||||
server_name=server_name,
|
|
||||||
report_stats=(config_args.report_stats == "yes"),
|
|
||||||
generate_secrets=True,
|
|
||||||
)
|
)
|
||||||
config = yaml.load(config_str)
|
|
||||||
obj.invoke_all("generate_files", config)
|
|
||||||
config_file.write(config_str)
|
config_file.write(config_str)
|
||||||
|
|
||||||
|
config = yaml.load(config_str)
|
||||||
|
obj.invoke_all("generate_files", config)
|
||||||
|
|
||||||
print(
|
print(
|
||||||
(
|
(
|
||||||
"A config file has been generated in %r for server name"
|
"A config file has been generated in %r for server name"
|
||||||
|
|
|
@ -49,7 +49,8 @@ class DatabaseConfig(Config):
|
||||||
def default_config(self, data_dir_path, **kwargs):
|
def default_config(self, data_dir_path, **kwargs):
|
||||||
database_path = os.path.join(data_dir_path, "homeserver.db")
|
database_path = os.path.join(data_dir_path, "homeserver.db")
|
||||||
return """\
|
return """\
|
||||||
# Database configuration
|
## Database ##
|
||||||
|
|
||||||
database:
|
database:
|
||||||
# The database engine name
|
# The database engine name
|
||||||
name: "sqlite3"
|
name: "sqlite3"
|
||||||
|
|
|
@ -81,7 +81,9 @@ class LoggingConfig(Config):
|
||||||
|
|
||||||
def default_config(self, config_dir_path, server_name, **kwargs):
|
def default_config(self, config_dir_path, server_name, **kwargs):
|
||||||
log_config = os.path.join(config_dir_path, server_name + ".log.config")
|
log_config = os.path.join(config_dir_path, server_name + ".log.config")
|
||||||
return """
|
return """\
|
||||||
|
## Logging ##
|
||||||
|
|
||||||
# A yaml python logging config file
|
# A yaml python logging config file
|
||||||
#
|
#
|
||||||
log_config: "%(log_config)s"
|
log_config: "%(log_config)s"
|
||||||
|
|
|
@ -260,9 +260,11 @@ class ServerConfig(Config):
|
||||||
# This is used by remote servers to connect to this server,
|
# This is used by remote servers to connect to this server,
|
||||||
# e.g. matrix.org, localhost:8080, etc.
|
# e.g. matrix.org, localhost:8080, etc.
|
||||||
# This is also the last part of your UserID.
|
# This is also the last part of your UserID.
|
||||||
|
#
|
||||||
server_name: "%(server_name)s"
|
server_name: "%(server_name)s"
|
||||||
|
|
||||||
# When running as a daemon, the file to store the pid in
|
# When running as a daemon, the file to store the pid in
|
||||||
|
#
|
||||||
pid_file: %(pid_file)s
|
pid_file: %(pid_file)s
|
||||||
|
|
||||||
# CPU affinity mask. Setting this restricts the CPUs on which the
|
# 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
|
# 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
|
# Zero is used to indicate synapse should set the soft limit to the
|
||||||
# hard limit.
|
# hard limit.
|
||||||
|
#
|
||||||
soft_file_limit: 0
|
soft_file_limit: 0
|
||||||
|
|
||||||
# Set to false to disable presence tracking on this homeserver.
|
# Set to false to disable presence tracking on this homeserver.
|
||||||
|
#
|
||||||
use_presence: true
|
use_presence: true
|
||||||
|
|
||||||
# The GC threshold parameters to pass to `gc.set_threshold`, if defined
|
# The GC threshold parameters to pass to `gc.set_threshold`, if defined
|
||||||
|
|
3
tox.ini
3
tox.ini
|
@ -118,6 +118,9 @@ commands =
|
||||||
python -m towncrier.check --compare-with=origin/develop
|
python -m towncrier.check --compare-with=origin/develop
|
||||||
basepython = python3.6
|
basepython = python3.6
|
||||||
|
|
||||||
|
[testenv:check-sampleconfig]
|
||||||
|
commands = {toxinidir}/scripts-dev/generate_sample_config --check
|
||||||
|
|
||||||
[testenv:codecov]
|
[testenv:codecov]
|
||||||
skip_install = True
|
skip_install = True
|
||||||
deps =
|
deps =
|
||||||
|
|
Loading…
Reference in New Issue