add synapse sync worker

This commit is contained in:
Daniel Micay 2025-12-21 02:54:49 -05:00
parent 3f2386da8a
commit 33f9d2adee
5 changed files with 55 additions and 2 deletions

View file

@ -1,4 +1,4 @@
/var/log/synapse/main.log /var/log/synapse/background.log /var/log/synapse/client_reader.log /var/log/synapse/federation_reader.log /var/log/synapse/federation_sender1.log /var/log/synapse/federation_sender2.log /var/log/synapse/federation_sender3.log /var/log/synapse/federation_sender4.log /var/log/synapse/media_repository.log /var/log/synapse/pusher.log /var/log/synapse/stream_writer.log {
/var/log/synapse/main.log /var/log/synapse/background.log /var/log/synapse/client_reader.log /var/log/synapse/federation_reader.log /var/log/synapse/federation_sender1.log /var/log/synapse/federation_sender2.log /var/log/synapse/federation_sender3.log /var/log/synapse/federation_sender4.log /var/log/synapse/media_repository.log /var/log/synapse/pusher.log /var/log/synapse/stream_writer.log /var/log/synapse/sync.log {
missingok
maxsize 1G
nodelaycompress

View file

@ -88,6 +88,11 @@ http {
server unix:/run/synapse/main_public.sock max_conns=4096 max_fails=0;
}
upstream synapse-sync {
zone synapse-sync 32k;
server unix:/run/synapse/sync_public.sock max_conns=4096 max_fails=0;
}
upstream synapse-client_reader {
zone synapse-client_reader 32k;
server unix:/run/synapse/client_reader_public.sock max_conns=4096 max_fails=0;
@ -185,7 +190,11 @@ http {
proxy_pass http://synapse-main;
location ~ ^/_matrix/client/(?:r0|v3)/sync$|^/_matrix/client/(?:api/v1|r0|v3)/events$|^/_matrix/client/(?:api/v1|r0|v3)/initialSync$|^/_matrix/client/(?:api/v1|r0|v3)/rooms/[^/]+/initialSync$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/createRoom$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/publicRooms$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/joined_members$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/context/.*$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/members$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/state$|^/_matrix/client/v1/rooms/.*/hierarchy$|^/_matrix/client/(?:v1|unstable)/rooms/.*/relations/|^/_matrix/client/v1/rooms/.*/threads$|^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$|^/_matrix/client/unstable/im.nheko.summary/summary/.*$|^/_matrix/client/(?:r0|v3|unstable)/account/3pid$|^/_matrix/client/(?:r0|v3|unstable)/account/whoami$|^/_matrix/client/(?:r0|v3|unstable)/account/deactivate$|^/_matrix/client/(?:r0|v3)/delete_devices$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/devices(?:/|$)|^/_matrix/client/versions$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/voip/turnServer$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/event/|^/_matrix/client/(?:api/v1|r0|v3|unstable)/joined_rooms$|^/_matrix/client/v1/rooms/.*/timestamp_to_event$|^/_matrix/client/(?:api/v1|r0|v3|unstable/.*)/rooms/.*/aliases|^/_matrix/client/(?:api/v1|r0|v3|unstable)/search$|^/_matrix/client/(?:r0|v3|unstable)/user/.*/filter(?:/|$)|^/_matrix/client/(?:api/v1|r0|v3|unstable)/directory/room/.*$|^/_matrix/client/(?:r0|v3|unstable)/capabilities$|^/_matrix/client/(?:r0|v3|unstable)/notifications$|^/_synapse/admin/v1/rooms/[^/]+$|^/_matrix/client/(?:r0|v3|unstable)/keys/query$|^/_matrix/client/(?:r0|v3|unstable)/keys/changes$|^/_matrix/client/(?:r0|v3|unstable)/keys/claim$|^/_matrix/client/(?:r0|v3|unstable)/room_keys/|^/_matrix/client/(?:r0|v3|unstable)/keys/upload|^/_matrix/client/(?:api/v1|r0|v3|unstable)/keys/device_signing/upload$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/keys/signatures/upload$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/login$|^/_matrix/client/(?:r0|v3|unstable)/register$|^/_matrix/client/(?:r0|v3|unstable)/register/available$|^/_matrix/client/v1/register/m.login.registration_token/validity$|^/_matrix/client/(?:r0|v3|unstable)/password_policy$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/redact|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/send|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/state/|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/(?:join|invite|leave|ban|unban|kick)$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/join/|^/_matrix/client/(?:api/v1|r0|v3|unstable)/knock/|^/_matrix/client/(?:api/v1|r0|v3|unstable)/profile/|^/_matrix/client/(?:r0|v3|unstable)/user_directory/search$|^/_matrix/client/unstable/org.matrix.msc4140/delayed_events(?:/.*/restart)?$|^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/messages$ {
location ~ ^/_matrix/client/(?:r0|v3)/sync$|^/_matrix/client/(?:api/v1|r0|v3)/events$|^/_matrix/client/(?:api/v1|r0|v3)/initialSync$|^/_matrix/client/(?:api/v1|r0|v3)/rooms/[^/]+/initialSync$ {
proxy_pass http://synapse-sync;
}
location ~ ^/_matrix/client/(?:api/v1|r0|v3|unstable)/createRoom$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/publicRooms$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/joined_members$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/context/.*$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/members$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/state$|^/_matrix/client/v1/rooms/.*/hierarchy$|^/_matrix/client/(?:v1|unstable)/rooms/.*/relations/|^/_matrix/client/v1/rooms/.*/threads$|^/_matrix/client/unstable/im.nheko.summary/rooms/.*/summary$|^/_matrix/client/unstable/im.nheko.summary/summary/.*$|^/_matrix/client/(?:r0|v3|unstable)/account/3pid$|^/_matrix/client/(?:r0|v3|unstable)/account/whoami$|^/_matrix/client/(?:r0|v3|unstable)/account/deactivate$|^/_matrix/client/(?:r0|v3)/delete_devices$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/devices(?:/|$)|^/_matrix/client/versions$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/voip/turnServer$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/event/|^/_matrix/client/(?:api/v1|r0|v3|unstable)/joined_rooms$|^/_matrix/client/v1/rooms/.*/timestamp_to_event$|^/_matrix/client/(?:api/v1|r0|v3|unstable/.*)/rooms/.*/aliases|^/_matrix/client/(?:api/v1|r0|v3|unstable)/search$|^/_matrix/client/(?:r0|v3|unstable)/user/.*/filter(?:/|$)|^/_matrix/client/(?:api/v1|r0|v3|unstable)/directory/room/.*$|^/_matrix/client/(?:r0|v3|unstable)/capabilities$|^/_matrix/client/(?:r0|v3|unstable)/notifications$|^/_synapse/admin/v1/rooms/[^/]+$|^/_matrix/client/(?:r0|v3|unstable)/keys/query$|^/_matrix/client/(?:r0|v3|unstable)/keys/changes$|^/_matrix/client/(?:r0|v3|unstable)/keys/claim$|^/_matrix/client/(?:r0|v3|unstable)/room_keys/|^/_matrix/client/(?:r0|v3|unstable)/keys/upload|^/_matrix/client/(?:api/v1|r0|v3|unstable)/keys/device_signing/upload$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/keys/signatures/upload$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/login$|^/_matrix/client/(?:r0|v3|unstable)/register$|^/_matrix/client/(?:r0|v3|unstable)/register/available$|^/_matrix/client/v1/register/m.login.registration_token/validity$|^/_matrix/client/(?:r0|v3|unstable)/password_policy$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/redact|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/send|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/state/|^/_matrix/client/(?:api/v1|r0|v3|unstable)/rooms/.*/(?:join|invite|leave|ban|unban|kick)$|^/_matrix/client/(?:api/v1|r0|v3|unstable)/join/|^/_matrix/client/(?:api/v1|r0|v3|unstable)/knock/|^/_matrix/client/(?:api/v1|r0|v3|unstable)/profile/|^/_matrix/client/(?:r0|v3|unstable)/user_directory/search$|^/_matrix/client/unstable/org.matrix.msc4140/delayed_events(?:/.*/restart)?$|^/_matrix/client/(api/v1|r0|v3|unstable)/rooms/.*/messages$ {
proxy_pass http://synapse-client_reader;
}

11
synapse/workers/sync.yaml Normal file
View file

@ -0,0 +1,11 @@
worker_app: synapse.app.generic_worker
worker_name: sync
worker_listeners:
- path: /run/synapse/sync_public.sock
mode: 0660
type: http
resources:
- names: [client]
worker_log_config: /etc/synapse/workers/sync_log_config.yaml

View file

@ -0,0 +1,23 @@
version: 1
formatters:
syslog_fmt:
format: '%(name)s: [%(request)s] %(message)s'
filters:
context:
(): synapse.logging.context.LoggingContextFilter
request: ""
handlers:
syslog:
class: logging.handlers.SysLogHandler
formatter: syslog_fmt
filters: [context]
address: /run/synapse-sync-log
root:
level: INFO
handlers: [syslog]
disable_existing_loggers: False

View file

@ -31,6 +31,9 @@ source s_synapse_pusher {
source s_synapse_stream_writer {
unix-dgram("/run/synapse-stream_writer-log" group("synapse") perm(0660));
};
source s_synapse_sync {
unix-dgram("/run/synapse-sync-log" group("synapse") perm(0660));
};
destination d_synapse_main {
file("/var/log/synapse/main.log" template("${ISODATE} ${LEVEL} ${MESSAGE}\n"));
@ -65,6 +68,9 @@ destination d_synapse_pusher {
destination d_synapse_stream_writer {
file("/var/log/synapse/stream_writer.log" template("${ISODATE} ${LEVEL} ${MESSAGE}\n"));
};
destination d_synapse_sync {
file("/var/log/synapse/sync.log" template("${ISODATE} ${LEVEL} ${MESSAGE}\n"));
};
log {
source(s_synapse_main);
@ -110,3 +116,7 @@ log {
source(s_synapse_stream_writer);
destination(d_synapse_stream_writer);
};
log {
source(s_synapse_sync);
destination(d_synapse_sync);
};