Fix config generation
This commit is contained in:
@@ -47,8 +47,8 @@ def set_config(config):
|
||||
if config_in_use():
|
||||
raise BasConfigInUseError()
|
||||
|
||||
for conf_name, conf in create_config(config).items():
|
||||
with open(abspath(join(get_config_dir, conf_name)), "w") as f:
|
||||
for conf_name, conf in create_config(config_dir, data_dir, config).items():
|
||||
with open(abspath(join(get_config_dir(), conf_name)), "w") as f:
|
||||
f.write(conf)
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ def generate_base_config(server_name, report_stats):
|
||||
if config_in_use():
|
||||
raise BasConfigInUseError()
|
||||
|
||||
print(config_dir)
|
||||
conf = HomeServerConfig().generate_config(
|
||||
config_dir,
|
||||
join(config_dir, DATA_SUBDIR),
|
||||
|
||||
@@ -3,15 +3,14 @@ from synapse.config.server import ServerConfig
|
||||
from synapse.config.tls import TlsConfig
|
||||
from synapse.config.logger import LoggingConfig
|
||||
from synapse.config.homeserver import HomeServerConfig
|
||||
from model import get_config_dir, get_data_dir, set_config_dir
|
||||
|
||||
|
||||
def create_config(conf):
|
||||
def create_config(config_dir_path, data_dir_path, conf):
|
||||
server_name = conf["server_name"]
|
||||
del conf["server_name"]
|
||||
|
||||
config_dir_path = get_config_dir()
|
||||
data_dir_path = get_data_dir()
|
||||
server_config_in_use = conf["server_config_in_use"]
|
||||
del conf["server_config_in_use"]
|
||||
|
||||
base_configs = [ServerConfig, DatabaseConfig, TlsConfig]
|
||||
|
||||
@@ -37,34 +36,9 @@ def create_config(conf):
|
||||
|
||||
rest_of_config = Configs().generate_config(**config_args)
|
||||
|
||||
return {"homeserver.yaml": base_config, "the_rest.yaml": rest_of_config}
|
||||
|
||||
|
||||
set_config_dir("/exampledir/")
|
||||
confs = create_config(
|
||||
{
|
||||
"server_name": "banterserver",
|
||||
"database": "sqlcrap",
|
||||
"listeners": [
|
||||
{
|
||||
"port": 8448,
|
||||
"resources": [{"names": ["federation"]}],
|
||||
"tls": True,
|
||||
"type": "http",
|
||||
},
|
||||
{
|
||||
"port": 443,
|
||||
"resources": [{"names": ["client"]}],
|
||||
"tls": False,
|
||||
"type": "http",
|
||||
},
|
||||
],
|
||||
"tls_certificate_path": "asdfasfdasdfadf",
|
||||
"tls_private_key_path": "asdfasfdha;kdfjhafd",
|
||||
"acme_domain": "asdfaklhsadfkj",
|
||||
"report_stats": True,
|
||||
return {
|
||||
"homeserver.yaml": base_config
|
||||
+ "\n\nserver_config_in_use: {}".format(server_config_in_use),
|
||||
"the_rest.yaml": rest_of_config,
|
||||
}
|
||||
)
|
||||
for conf_name, conf in confs.items():
|
||||
with open(conf_name, "w") as f:
|
||||
f.write(conf)
|
||||
|
||||
|
||||
@@ -18,7 +18,7 @@ BASE_CONFIG_SCHEMA = {
|
||||
"pid_file": {"type": "string", "minlength": 1},
|
||||
"listeners": {"type": "array"},
|
||||
"acme": {"type": "object"},
|
||||
"database": {"type": "object"},
|
||||
"database": {"type": "string", "minlength": 1},
|
||||
"tls_certificate_path": {"type": "string", "minlength": 1},
|
||||
"tls_private_key_path": {"type": "string", "minlength": 1},
|
||||
"server_config_in_use": {"type": "boolean"},
|
||||
|
||||
Reference in New Issue
Block a user