mirror of
https://github.com/element-hq/synapse.git
synced 2024-11-21 09:05:42 +03:00
Add application_name
s to the postgres connections based on the worker names
This commit is contained in:
parent
1e73e7dde2
commit
b21487300c
3 changed files with 22 additions and 0 deletions
|
@ -27,4 +27,19 @@ worker_listeners:
|
|||
|
||||
worker_log_config: {{ worker_log_config_filepath }}
|
||||
|
||||
database:
|
||||
name: "psycopg2"
|
||||
args:
|
||||
user: "{{ POSTGRES_USER or "synapse" }}"
|
||||
password: "{{ POSTGRES_PASSWORD }}"
|
||||
database: "{{ POSTGRES_DB or "synapse" }}"
|
||||
{% if not SYNAPSE_USE_UNIX_SOCKET %}
|
||||
{# Synapse will use a default unix socket for Postgres when host/port is not specified (behavior from `psycopg2`). #}
|
||||
host: "{{ POSTGRES_HOST or "db" }}"
|
||||
port: "{{ POSTGRES_PORT or "5432" }}"
|
||||
{% endif %}
|
||||
cp_min: {{ POSTGRES_CP_MIN or 5 }}
|
||||
cp_max: {{ POSTGRES_CP_MAX or 10 }}
|
||||
application_name: "{{ name }}"
|
||||
|
||||
{{ worker_extra_conf }}
|
||||
|
|
|
@ -69,6 +69,7 @@ database:
|
|||
{% endif %}
|
||||
cp_min: {{ POSTGRES_CP_MIN or 5 }}
|
||||
cp_max: {{ POSTGRES_CP_MAX or 10 }}
|
||||
application_name: synapse
|
||||
{% else %}
|
||||
database:
|
||||
name: "sqlite3"
|
||||
|
|
|
@ -962,11 +962,17 @@ def generate_worker_files(
|
|||
environ, worker_name, workers_config_dir, template_dir, data_dir
|
||||
)
|
||||
|
||||
extra_env: Dict[str, str] = {}
|
||||
for extra_env_var in ("POSTGRES_HOST", "POSTGRES_PORT", "POSTGRES_USER", "POSTGRES_PASSWORD", "POSTGRES_SOCKET", "POSTGRES_DB", "SYNAPSE_USE_UNIX_SOCKET", "POSTGRES_CP_MIN", "POSTGRES_CP_MAX"):
|
||||
if extra_env_var in os.environ:
|
||||
extra_env[extra_env_var] = os.environ[extra_env_var]
|
||||
|
||||
# Then a worker config file
|
||||
convert(
|
||||
os.path.join(template_dir, "worker.yaml.j2"),
|
||||
os.path.join(workers_config_dir, f"{worker_name}.yaml"),
|
||||
**worker_config,
|
||||
**extra_env,
|
||||
worker_log_config_filepath=log_config_filepath,
|
||||
using_unix_sockets=using_unix_sockets,
|
||||
)
|
||||
|
|
Loading…
Reference in a new issue