mirror of
https://github.com/element-hq/synapse.git
synced 2025-12-07 01:20:16 +00:00
Compare commits
7 Commits
v1.136.0rc
...
anoa/worke
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f4f5a706f8 | ||
|
|
28245e3908 | ||
|
|
b9c50043e0 | ||
|
|
e48479978b | ||
|
|
5caca2acd6 | ||
|
|
d3ed0ebebd | ||
|
|
af2a16370d |
@@ -24,6 +24,15 @@
|
|||||||
# nginx and supervisord configs depending on the workers requested.
|
# nginx and supervisord configs depending on the workers requested.
|
||||||
#
|
#
|
||||||
# The environment variables it reads are:
|
# The environment variables it reads are:
|
||||||
|
# * SYNAPSE_CONFIG_PATH: The path where the generated `homeserver.yaml` will
|
||||||
|
# be stored.
|
||||||
|
# * SYNAPSE_CONFIG_DIR: The directory where generated config will be stored.
|
||||||
|
# If `SYNAPSE_CONFIG_PATH` is not set, it will default to
|
||||||
|
# SYNAPSE_CONFIG_DIR/homeserver.yaml.
|
||||||
|
# * SYNAPSE_DATA_DIR: Where the generated config will put persistent data
|
||||||
|
# such as the database and media store.
|
||||||
|
# * SYNAPSE_CONFIG_TEMPLATE_DIR: The directory containing jinja2 templates for
|
||||||
|
# configuration that this script will generate config from. Defaults to '/conf'.
|
||||||
# * SYNAPSE_SERVER_NAME: The desired server_name of the homeserver.
|
# * SYNAPSE_SERVER_NAME: The desired server_name of the homeserver.
|
||||||
# * SYNAPSE_REPORT_STATS: Whether to report stats.
|
# * SYNAPSE_REPORT_STATS: Whether to report stats.
|
||||||
# * SYNAPSE_WORKER_TYPES: A comma separated list of worker names as specified in WORKERS_CONFIG
|
# * SYNAPSE_WORKER_TYPES: A comma separated list of worker names as specified in WORKERS_CONFIG
|
||||||
@@ -35,6 +44,8 @@
|
|||||||
# SYNAPSE_WORKER_TYPES='event_persister, federation_sender, client_reader'
|
# SYNAPSE_WORKER_TYPES='event_persister, federation_sender, client_reader'
|
||||||
# SYNAPSE_WORKER_TYPES='event_persister:2, federation_sender:2, client_reader'
|
# SYNAPSE_WORKER_TYPES='event_persister:2, federation_sender:2, client_reader'
|
||||||
# SYNAPSE_WORKER_TYPES='stream_writers=account_data+presence+typing'
|
# SYNAPSE_WORKER_TYPES='stream_writers=account_data+presence+typing'
|
||||||
|
# * SYNAPSE_WORKERS_WRITE_LOGS_TO_DISK: Whether worker logs should be written to disk,
|
||||||
|
# in addition to stdout.
|
||||||
# * SYNAPSE_AS_REGISTRATION_DIR: If specified, a directory in which .yaml and .yml files
|
# * SYNAPSE_AS_REGISTRATION_DIR: If specified, a directory in which .yaml and .yml files
|
||||||
# will be treated as Application Service registration files.
|
# will be treated as Application Service registration files.
|
||||||
# * SYNAPSE_TLS_CERT: Path to a TLS certificate in PEM format.
|
# * SYNAPSE_TLS_CERT: Path to a TLS certificate in PEM format.
|
||||||
@@ -48,7 +59,9 @@
|
|||||||
# * SYNAPSE_LOG_SENSITIVE: If unset, SQL and SQL values won't be logged,
|
# * SYNAPSE_LOG_SENSITIVE: If unset, SQL and SQL values won't be logged,
|
||||||
# regardless of the SYNAPSE_LOG_LEVEL setting.
|
# regardless of the SYNAPSE_LOG_LEVEL setting.
|
||||||
# * SYNAPSE_LOG_TESTING: if set, Synapse will log additional information useful
|
# * SYNAPSE_LOG_TESTING: if set, Synapse will log additional information useful
|
||||||
# for testing.
|
# for testing.
|
||||||
|
# * SYNAPSE_USE_UNIX_SOCKET: if set, workers will communicate via unix socket
|
||||||
|
# rather than TCP.
|
||||||
#
|
#
|
||||||
# NOTE: According to Complement's ENTRYPOINT expectations for a homeserver image (as defined
|
# NOTE: According to Complement's ENTRYPOINT expectations for a homeserver image (as defined
|
||||||
# in the project's README), this script may be run multiple times, and functionality should
|
# in the project's README), this script may be run multiple times, and functionality should
|
||||||
@@ -604,7 +617,9 @@ def generate_base_homeserver_config() -> None:
|
|||||||
# start.py already does this for us, so just call that.
|
# start.py already does this for us, so just call that.
|
||||||
# note that this script is copied in in the official, monolith dockerfile
|
# note that this script is copied in in the official, monolith dockerfile
|
||||||
os.environ["SYNAPSE_HTTP_PORT"] = str(MAIN_PROCESS_HTTP_LISTENER_PORT)
|
os.environ["SYNAPSE_HTTP_PORT"] = str(MAIN_PROCESS_HTTP_LISTENER_PORT)
|
||||||
subprocess.run(["/usr/local/bin/python", "/start.py", "migrate_config"], check=True)
|
|
||||||
|
# This script makes use of the `SYNAPSE_CONFIG_DIR` environment variable to
|
||||||
|
# determine where to place the generated homeserver config.
|
||||||
|
|
||||||
|
|
||||||
def parse_worker_types(
|
def parse_worker_types(
|
||||||
@@ -733,8 +748,10 @@ def parse_worker_types(
|
|||||||
|
|
||||||
def generate_worker_files(
|
def generate_worker_files(
|
||||||
environ: Mapping[str, str],
|
environ: Mapping[str, str],
|
||||||
|
config_dir: str,
|
||||||
config_path: str,
|
config_path: str,
|
||||||
data_dir: str,
|
data_dir: str,
|
||||||
|
template_dir: str,
|
||||||
requested_worker_types: Dict[str, Set[str]],
|
requested_worker_types: Dict[str, Set[str]],
|
||||||
) -> None:
|
) -> None:
|
||||||
"""Read the desired workers(if any) that is passed in and generate shared
|
"""Read the desired workers(if any) that is passed in and generate shared
|
||||||
@@ -742,9 +759,13 @@ def generate_worker_files(
|
|||||||
|
|
||||||
Args:
|
Args:
|
||||||
environ: os.environ instance.
|
environ: os.environ instance.
|
||||||
config_path: The location of the generated Synapse main worker config file.
|
config_dir: The location of the configuration directory, where generated
|
||||||
data_dir: The location of the synapse data directory. Where log and
|
worker config files are written to.
|
||||||
user-facing config files live.
|
config_path: The location of the base Synapse homeserver config file.
|
||||||
|
data_dir: The location of the synapse data directory. Where logs will be
|
||||||
|
stored (if `SYNAPSE_WORKERS_WRITE_LOGS_TO_DISK` is set).
|
||||||
|
template_dir: The location of the template directory. Where jinja2
|
||||||
|
templates for config files live.
|
||||||
requested_worker_types: A Dict containing requested workers in the format of
|
requested_worker_types: A Dict containing requested workers in the format of
|
||||||
{'worker_name1': {'worker_type', ...}}
|
{'worker_name1': {'worker_type', ...}}
|
||||||
"""
|
"""
|
||||||
@@ -807,7 +828,8 @@ def generate_worker_files(
|
|||||||
nginx_locations: Dict[str, str] = {}
|
nginx_locations: Dict[str, str] = {}
|
||||||
|
|
||||||
# Create the worker configuration directory if it doesn't already exist
|
# Create the worker configuration directory if it doesn't already exist
|
||||||
os.makedirs("/conf/workers", exist_ok=True)
|
workers_config_dir = os.path.join(config_dir, "workers")
|
||||||
|
os.makedirs(workers_config_dir, exist_ok=True)
|
||||||
|
|
||||||
# Start worker ports from this arbitrary port
|
# Start worker ports from this arbitrary port
|
||||||
worker_port = 18009
|
worker_port = 18009
|
||||||
@@ -854,7 +876,7 @@ def generate_worker_files(
|
|||||||
worker_config = insert_worker_name_for_worker_config(worker_config, worker_name)
|
worker_config = insert_worker_name_for_worker_config(worker_config, worker_name)
|
||||||
|
|
||||||
worker_config.update(
|
worker_config.update(
|
||||||
{"name": worker_name, "port": str(worker_port), "config_path": config_path}
|
{"name": worker_name, "port": str(worker_port)}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Update the shared config with any worker_type specific options. The first of a
|
# Update the shared config with any worker_type specific options. The first of a
|
||||||
@@ -877,12 +899,14 @@ def generate_worker_files(
|
|||||||
worker_descriptors.append(worker_config)
|
worker_descriptors.append(worker_config)
|
||||||
|
|
||||||
# Write out the worker's logging config file
|
# Write out the worker's logging config file
|
||||||
log_config_filepath = generate_worker_log_config(environ, worker_name, data_dir)
|
log_config_filepath = generate_worker_log_config(
|
||||||
|
environ, worker_name, template_dir, workers_config_dir, data_dir
|
||||||
|
)
|
||||||
|
|
||||||
# Then a worker config file
|
# Then a worker config file
|
||||||
convert(
|
convert(
|
||||||
"/conf/worker.yaml.j2",
|
os.path.join(template_dir, "worker.yaml.j2"),
|
||||||
f"/conf/workers/{worker_name}.yaml",
|
os.path.join(workers_config_dir, f"{worker_name}.yaml"),
|
||||||
**worker_config,
|
**worker_config,
|
||||||
worker_log_config_filepath=log_config_filepath,
|
worker_log_config_filepath=log_config_filepath,
|
||||||
using_unix_sockets=using_unix_sockets,
|
using_unix_sockets=using_unix_sockets,
|
||||||
@@ -923,7 +947,9 @@ def generate_worker_files(
|
|||||||
# Finally, we'll write out the config files.
|
# Finally, we'll write out the config files.
|
||||||
|
|
||||||
# log config for the master process
|
# log config for the master process
|
||||||
master_log_config = generate_worker_log_config(environ, "master", data_dir)
|
master_log_config = generate_worker_log_config(
|
||||||
|
environ, "master", template_dir, workers_config_dir, data_dir
|
||||||
|
)
|
||||||
shared_config["log_config"] = master_log_config
|
shared_config["log_config"] = master_log_config
|
||||||
|
|
||||||
# Find application service registrations
|
# Find application service registrations
|
||||||
@@ -954,8 +980,8 @@ def generate_worker_files(
|
|||||||
|
|
||||||
# Shared homeserver config
|
# Shared homeserver config
|
||||||
convert(
|
convert(
|
||||||
"/conf/shared.yaml.j2",
|
os.path.join(template_dir, "shared.yaml.j2"),
|
||||||
"/conf/workers/shared.yaml",
|
os.path.join(workers_config_dir, "shared.yaml"),
|
||||||
shared_worker_config=yaml.dump(shared_config),
|
shared_worker_config=yaml.dump(shared_config),
|
||||||
appservice_registrations=appservice_registrations,
|
appservice_registrations=appservice_registrations,
|
||||||
enable_redis=workers_in_use,
|
enable_redis=workers_in_use,
|
||||||
@@ -965,7 +991,7 @@ def generate_worker_files(
|
|||||||
|
|
||||||
# Nginx config
|
# Nginx config
|
||||||
convert(
|
convert(
|
||||||
"/conf/nginx.conf.j2",
|
os.path.join(template_dir, "nginx.conf.j2"),
|
||||||
"/etc/nginx/conf.d/matrix-synapse.conf",
|
"/etc/nginx/conf.d/matrix-synapse.conf",
|
||||||
worker_locations=nginx_location_config,
|
worker_locations=nginx_location_config,
|
||||||
upstream_directives=nginx_upstream_config,
|
upstream_directives=nginx_upstream_config,
|
||||||
@@ -977,7 +1003,7 @@ def generate_worker_files(
|
|||||||
# Supervisord config
|
# Supervisord config
|
||||||
os.makedirs("/etc/supervisor", exist_ok=True)
|
os.makedirs("/etc/supervisor", exist_ok=True)
|
||||||
convert(
|
convert(
|
||||||
"/conf/supervisord.conf.j2",
|
os.path.join(template_dir, "supervisord.conf.j2"),
|
||||||
"/etc/supervisor/supervisord.conf",
|
"/etc/supervisor/supervisord.conf",
|
||||||
main_config_path=config_path,
|
main_config_path=config_path,
|
||||||
enable_redis=workers_in_use,
|
enable_redis=workers_in_use,
|
||||||
@@ -985,7 +1011,7 @@ def generate_worker_files(
|
|||||||
)
|
)
|
||||||
|
|
||||||
convert(
|
convert(
|
||||||
"/conf/synapse.supervisord.conf.j2",
|
os.path.join(template_dir, "synapse.supervisord.conf.j2"),
|
||||||
"/etc/supervisor/conf.d/synapse.conf",
|
"/etc/supervisor/conf.d/synapse.conf",
|
||||||
workers=worker_descriptors,
|
workers=worker_descriptors,
|
||||||
main_config_path=config_path,
|
main_config_path=config_path,
|
||||||
@@ -994,7 +1020,7 @@ def generate_worker_files(
|
|||||||
|
|
||||||
# healthcheck config
|
# healthcheck config
|
||||||
convert(
|
convert(
|
||||||
"/conf/healthcheck.sh.j2",
|
os.path.join(template_dir, "healthcheck.sh.j2"),
|
||||||
"/healthcheck.sh",
|
"/healthcheck.sh",
|
||||||
healthcheck_urls=healthcheck_urls,
|
healthcheck_urls=healthcheck_urls,
|
||||||
)
|
)
|
||||||
@@ -1006,10 +1032,24 @@ def generate_worker_files(
|
|||||||
|
|
||||||
|
|
||||||
def generate_worker_log_config(
|
def generate_worker_log_config(
|
||||||
environ: Mapping[str, str], worker_name: str, data_dir: str
|
environ: Mapping[str, str],
|
||||||
|
worker_name: str,
|
||||||
|
workers_config_dir: str,
|
||||||
|
template_dir: str,
|
||||||
|
data_dir: str,
|
||||||
) -> str:
|
) -> str:
|
||||||
"""Generate a log.config file for the given worker.
|
"""Generate a log.config file for the given worker.
|
||||||
|
|
||||||
|
Args:
|
||||||
|
environ: A mapping representing the environment variables that this script
|
||||||
|
is running with.
|
||||||
|
worker_name: The name of the worker. Used in generated file paths.
|
||||||
|
workers_config_dir: The location of the worker configuration directory,
|
||||||
|
where the generated worker log config will be saved.
|
||||||
|
template_dir: The directory containing jinja2 template files.
|
||||||
|
data_dir: The directory where log files will be written (if
|
||||||
|
`SYNAPSE_WORKERS_WRITE_LOGS_TO_DISK` is set).
|
||||||
|
|
||||||
Returns: the path to the generated file
|
Returns: the path to the generated file
|
||||||
"""
|
"""
|
||||||
# Check whether we should write worker logs to disk, in addition to the console
|
# Check whether we should write worker logs to disk, in addition to the console
|
||||||
@@ -1024,9 +1064,9 @@ def generate_worker_log_config(
|
|||||||
extra_log_template_args["SYNAPSE_LOG_TESTING"] = environ.get("SYNAPSE_LOG_TESTING")
|
extra_log_template_args["SYNAPSE_LOG_TESTING"] = environ.get("SYNAPSE_LOG_TESTING")
|
||||||
|
|
||||||
# Render and write the file
|
# Render and write the file
|
||||||
log_config_filepath = f"/conf/workers/{worker_name}.log.config"
|
log_config_filepath = os.path.join(workers_config_dir, f"{worker_name}.log.config")
|
||||||
convert(
|
convert(
|
||||||
"/conf/log.config",
|
os.path.join(template_dir, "log.config"),
|
||||||
log_config_filepath,
|
log_config_filepath,
|
||||||
worker_name=worker_name,
|
worker_name=worker_name,
|
||||||
**extra_log_template_args,
|
**extra_log_template_args,
|
||||||
@@ -1049,6 +1089,7 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
|
|||||||
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")
|
||||||
|
|
||||||
# override SYNAPSE_NO_TLS, we don't support TLS in worker mode,
|
# override SYNAPSE_NO_TLS, we don't support TLS in worker mode,
|
||||||
# this needs to be handled by a frontend proxy
|
# this needs to be handled by a frontend proxy
|
||||||
@@ -1060,9 +1101,10 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
|
|||||||
generate_base_homeserver_config()
|
generate_base_homeserver_config()
|
||||||
else:
|
else:
|
||||||
log("Base homeserver config exists—not regenerating")
|
log("Base homeserver config exists—not regenerating")
|
||||||
|
|
||||||
# This script may be run multiple times (mostly by Complement, see note at top of
|
# This script may be run multiple times (mostly by Complement, see note at top of
|
||||||
# file). Don't re-configure workers in this instance.
|
# file). Don't re-configure workers in this instance.
|
||||||
mark_filepath = "/conf/workers_have_been_configured"
|
mark_filepath = os.path.join(config_dir, "workers_have_been_configured")
|
||||||
if not os.path.exists(mark_filepath):
|
if not os.path.exists(mark_filepath):
|
||||||
# Collect and validate worker_type requests
|
# Collect and validate worker_type requests
|
||||||
# Read the desired worker configuration from the environment
|
# Read the desired worker configuration from the environment
|
||||||
@@ -1079,7 +1121,9 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
|
|||||||
|
|
||||||
# Always regenerate all other config files
|
# Always regenerate all other config files
|
||||||
log("Generating worker config files")
|
log("Generating worker config files")
|
||||||
generate_worker_files(environ, config_path, data_dir, requested_worker_types)
|
generate_worker_files(
|
||||||
|
environ, config_dir, config_path, data_dir, template_dir, requested_worker_types
|
||||||
|
)
|
||||||
|
|
||||||
# Mark workers as being configured
|
# Mark workers as being configured
|
||||||
with open(mark_filepath, "w") as f:
|
with open(mark_filepath, "w") as f:
|
||||||
|
|||||||
@@ -42,6 +42,8 @@ def convert(src: str, dst: str, environ: Mapping[str, object]) -> None:
|
|||||||
|
|
||||||
|
|
||||||
def generate_config_from_template(
|
def generate_config_from_template(
|
||||||
|
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],
|
||||||
@@ -50,6 +52,9 @@ def generate_config_from_template(
|
|||||||
"""Generate a homeserver.yaml from environment variables
|
"""Generate a homeserver.yaml from environment variables
|
||||||
|
|
||||||
Args:
|
Args:
|
||||||
|
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
|
||||||
@@ -70,9 +75,10 @@ def generate_config_from_template(
|
|||||||
"macaroon": "SYNAPSE_MACAROON_SECRET_KEY",
|
"macaroon": "SYNAPSE_MACAROON_SECRET_KEY",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
synapse_server_name = environ["SYNAPSE_SERVER_NAME"]
|
||||||
for name, secret in secrets.items():
|
for name, secret in secrets.items():
|
||||||
if secret not in environ:
|
if secret not in environ:
|
||||||
filename = "/data/%s.%s.key" % (environ["SYNAPSE_SERVER_NAME"], name)
|
filename = os.path.join(data_dir, f"{synapse_server_name}.{name}.key")
|
||||||
|
|
||||||
# if the file already exists, load in the existing value; otherwise,
|
# if the file already exists, load in the existing value; otherwise,
|
||||||
# generate a new secret and write it to a file
|
# generate a new secret and write it to a file
|
||||||
@@ -88,7 +94,7 @@ def generate_config_from_template(
|
|||||||
handle.write(value)
|
handle.write(value)
|
||||||
environ[secret] = value
|
environ[secret] = value
|
||||||
|
|
||||||
environ["SYNAPSE_APPSERVICES"] = glob.glob("/data/appservices/*.yaml")
|
environ["SYNAPSE_APPSERVICES"] = glob.glob(os.path.join(data_dir, "appservices", "*.yaml"))
|
||||||
if not os.path.exists(config_dir):
|
if not os.path.exists(config_dir):
|
||||||
os.mkdir(config_dir)
|
os.mkdir(config_dir)
|
||||||
|
|
||||||
@@ -111,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},
|
||||||
)
|
)
|
||||||
@@ -128,15 +134,15 @@ def generate_config_from_template(
|
|||||||
"synapse.app.homeserver",
|
"synapse.app.homeserver",
|
||||||
"--config-path",
|
"--config-path",
|
||||||
config_path,
|
config_path,
|
||||||
# tell synapse to put generated keys in /data rather than /compiled
|
# tell synapse to put generated keys in the data directory rather than /compiled
|
||||||
"--keys-directory",
|
"--keys-directory",
|
||||||
config_dir,
|
config_dir,
|
||||||
"--generate-keys",
|
"--generate-keys",
|
||||||
]
|
]
|
||||||
|
|
||||||
if ownership is not None:
|
if ownership is not None:
|
||||||
log(f"Setting ownership on /data to {ownership}")
|
log(f"Setting ownership on the data dir to {ownership}")
|
||||||
subprocess.run(["chown", "-R", ownership, "/data"], check=True)
|
subprocess.run(["chown", "-R", ownership, data_dir], check=True)
|
||||||
args = ["gosu", ownership] + args
|
args = ["gosu", ownership] + args
|
||||||
|
|
||||||
subprocess.run(args, check=True)
|
subprocess.run(args, check=True)
|
||||||
@@ -159,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 = [
|
||||||
@@ -216,12 +223,14 @@ def main(args: List[str], environ: MutableMapping[str, str]) -> None:
|
|||||||
|
|
||||||
if mode == "migrate_config":
|
if mode == "migrate_config":
|
||||||
# generate a config based on environment vars.
|
# generate a config based on environment vars.
|
||||||
|
data_dir = environ.get("SYNAPSE_DATA_DIR", "/data")
|
||||||
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
|
config_dir = environ.get("SYNAPSE_CONFIG_DIR", "/data")
|
||||||
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(
|
||||||
config_dir, config_path, environ, ownership
|
data_dir, template_dir, config_dir, config_path, environ, ownership
|
||||||
)
|
)
|
||||||
|
|
||||||
if mode != "run":
|
if mode != "run":
|
||||||
|
|||||||
Reference in New Issue
Block a user