mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-27 03:58:06 +03:00
start.py: Support SYNAPSE_CONFIG_TEMPLATE_DIR
This commit is contained in:
parent
28245e3908
commit
f4f5a706f8
1 changed files with 9 additions and 4 deletions
|
@ -43,6 +43,7 @@ def convert(src: str, dst: str, environ: Mapping[str, object]) -> None:
|
||||||
|
|
||||||
def generate_config_from_template(
|
def generate_config_from_template(
|
||||||
data_dir: str,
|
data_dir: str,
|
||||||
|
template_dir: str,
|
||||||
config_dir: str,
|
config_dir: str,
|
||||||
config_path: str,
|
config_path: str,
|
||||||
os_environ: Mapping[str, str],
|
os_environ: Mapping[str, str],
|
||||||
|
@ -52,6 +53,8 @@ def generate_config_from_template(
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
data_dir: where persistent data is stored
|
data_dir: where persistent data is stored
|
||||||
|
template_dir: The location of the template directory. Where jinja2
|
||||||
|
templates for config files live.
|
||||||
config_dir: where to put generated config files
|
config_dir: where to put generated config files
|
||||||
config_path: where to put the main config file
|
config_path: where to put the main config file
|
||||||
os_environ: environment mapping
|
os_environ: environment mapping
|
||||||
|
@ -114,12 +117,12 @@ def generate_config_from_template(
|
||||||
environ["SYNAPSE_LOG_CONFIG"] = config_dir + "/log.config"
|
environ["SYNAPSE_LOG_CONFIG"] = config_dir + "/log.config"
|
||||||
|
|
||||||
log("Generating synapse config file " + config_path)
|
log("Generating synapse config file " + config_path)
|
||||||
convert("/conf/homeserver.yaml", config_path, environ)
|
convert(os.path.join(template_dir, "homeserver.yaml"), config_path, environ)
|
||||||
|
|
||||||
log_config_file = environ["SYNAPSE_LOG_CONFIG"]
|
log_config_file = environ["SYNAPSE_LOG_CONFIG"]
|
||||||
log("Generating log config file " + log_config_file)
|
log("Generating log config file " + log_config_file)
|
||||||
convert(
|
convert(
|
||||||
"/conf/log.config",
|
os.path.join(template_dir, "log.config"),
|
||||||
log_config_file,
|
log_config_file,
|
||||||
{**environ, "include_worker_name_in_log_line": False},
|
{**environ, "include_worker_name_in_log_line": False},
|
||||||
)
|
)
|
||||||
|
@ -162,12 +165,13 @@ def run_generate_config(environ: Mapping[str, str], ownership: Optional[str]) ->
|
||||||
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
|
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
|
||||||
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
|
config_path = environ.get("SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml")
|
||||||
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
|
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
|
||||||
|
template_dir = environ.get("SYNAPSE_CONFIG_TEMPLATE_DIR", "/conf")
|
||||||
|
|
||||||
# create a suitable log config from our template
|
# create a suitable log config from our template
|
||||||
log_config_file = "%s/%s.log.config" % (config_dir, server_name)
|
log_config_file = "%s/%s.log.config" % (config_dir, server_name)
|
||||||
if not os.path.exists(log_config_file):
|
if not os.path.exists(log_config_file):
|
||||||
log("Creating log config %s" % (log_config_file,))
|
log("Creating log config %s" % (log_config_file,))
|
||||||
convert("/conf/log.config", log_config_file, environ)
|
convert(os.path.join(template_dir, "log.config"), log_config_file, environ)
|
||||||
|
|
||||||
# generate the main config file, and a signing key.
|
# generate the main config file, and a signing key.
|
||||||
args = [
|
args = [
|
||||||
|
@ -224,8 +228,9 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
|
||||||
config_path = environ.get(
|
config_path = environ.get(
|
||||||
"SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml"
|
"SYNAPSE_CONFIG_PATH", config_dir + "/homeserver.yaml"
|
||||||
)
|
)
|
||||||
|
template_dir = environ.get("SYNAPSE_CONFIG_TEMPLATE_DIR", "/conf")
|
||||||
return generate_config_from_template(
|
return generate_config_from_template(
|
||||||
data_dir, config_dir, config_path, environ, ownership
|
data_dir, template_dir, config_dir, config_path, environ, ownership
|
||||||
)
|
)
|
||||||
|
|
||||||
if mode != "run":
|
if mode != "run":
|
||||||
|
|
Loading…
Reference in a new issue