forked from Fediversity/Fediversity
Moved a few parts to different locations.
This commit is contained in:
parent
3608f37fd5
commit
62f540f521
|
@ -80,13 +80,33 @@ Restart Redis for these changes to take effect. Check for error messages in
|
||||||
the logs, if port 6379 is no longer active, and if the socketfile
|
the logs, if port 6379 is no longer active, and if the socketfile
|
||||||
`/run/redis/redis-server.sock` exists.
|
`/run/redis/redis-server.sock` exists.
|
||||||
|
|
||||||
|
Now point Synapse at Redis in `conf.d/redis.yaml`:
|
||||||
|
|
||||||
|
```
|
||||||
|
redis:
|
||||||
|
enabled: true
|
||||||
|
path: /run/redis/redis-server.sock
|
||||||
|
```
|
||||||
|
|
||||||
|
Restart Synapse and check if it can connect to Redis via the socket, you should find log
|
||||||
|
entries like this:
|
||||||
|
|
||||||
|
```
|
||||||
|
synapse.replication.tcp.redis - 292 - INFO - sentinel - Connecting to redis server UNIXAddress('/run/redis/redis-server.sock')
|
||||||
|
synapse.util.httpresourcetree - 56 - INFO - sentinel - Attaching <synapse.replication.http.ReplicationRestResource object at 0x7f95f850d150> to path b'/_synapse/replication'
|
||||||
|
synapse.replication.tcp.redis - 126 - INFO - sentinel - Connected to redis
|
||||||
|
synapse.replication.tcp.redis - 138 - INFO - subscribe-replication-0 - Sending redis SUBSCRIBE for ['matrix.example.com/USER_IP', 'matrix.example.com']
|
||||||
|
synapse.replication.tcp.redis - 141 - INFO - subscribe-replication-0 - Successfully subscribed to redis stream, sending REPLICATE command
|
||||||
|
synapse.replication.tcp.redis - 146 - INFO - subscribe-replication-0 - REPLICATE successfully sent
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
# Synapse
|
# Synapse
|
||||||
|
|
||||||
Workers communicate with each other over sockets, that are all placed in one
|
Workers communicate with each other over sockets, that are all placed in one
|
||||||
directory. To make sure only the users that need access will have it, we
|
directory. These sockets are owned by `matrix-synapse:matrix-synapse`, so make
|
||||||
create a new group and add the users to it. Remember that nginx needs to be
|
sure nginx can write to them: add user `www-data` to group `matrix-synapse`
|
||||||
able to write to many of these sockets.
|
and restart nginx.
|
||||||
|
|
||||||
Then, make sure systemd creates the directory for the sockets as soon as
|
Then, make sure systemd creates the directory for the sockets as soon as
|
||||||
Synapse starts, and let it have the correct group.
|
Synapse starts, and let it have the correct group.
|
||||||
|
@ -109,9 +129,9 @@ would create problems with workers who suddenly lose their sockets.
|
||||||
|
|
||||||
Then we change Synapse from listening on `localhost:8008` to listening on a
|
Then we change Synapse from listening on `localhost:8008` to listening on a
|
||||||
socket. We'll do most of our workers work in `conf.d/listeners.yaml`, so let's
|
socket. We'll do most of our workers work in `conf.d/listeners.yaml`, so let's
|
||||||
put the new configuration for the main proccess there.
|
put the new listener configuration for the main proccess there.
|
||||||
|
|
||||||
Remove the `localhost:8008` bit, and configure these two sockets:
|
Remove the `localhost:8008` stanza, and configure these two sockets:
|
||||||
|
|
||||||
```
|
```
|
||||||
listeners:
|
listeners:
|
||||||
|
@ -150,35 +170,11 @@ to
|
||||||
proxy_forward http://unix:/run/matrix-synapse/inbound_main.sock;
|
proxy_forward http://unix:/run/matrix-synapse/inbound_main.sock;
|
||||||
```
|
```
|
||||||
|
|
||||||
Because the sockets under `/run/matrix-synapse` are writable only by user and
|
|
||||||
group `matrix-synapse`, we have to add nginx to that group:
|
|
||||||
|
|
||||||
```
|
|
||||||
addgroup www-data matrix-synapse
|
|
||||||
```
|
|
||||||
|
|
||||||
This may not be the best way, but for now it will suffice.
|
|
||||||
|
|
||||||
If you've done this, restart Synapse and nginx, and check if the sockets are created
|
If you've done this, restart Synapse and nginx, and check if the sockets are created
|
||||||
and have the correct permissions. Now point Synapse at Redis in `conf.d/redis.yaml`:
|
and have the correct permissions.
|
||||||
|
|
||||||
```
|
Synapse should work normally again, we've switched from network sockets to
|
||||||
redis:
|
UNIX sockets, and added Redis. Now we'll create the actual workers.
|
||||||
enabled: true
|
|
||||||
path: /run/redis/redis-server.sock
|
|
||||||
```
|
|
||||||
|
|
||||||
Restart Synapse and check if it can connect to Redis via the socket, you should find log
|
|
||||||
entries like this:
|
|
||||||
|
|
||||||
```
|
|
||||||
synapse.replication.tcp.redis - 292 - INFO - sentinel - Connecting to redis server UNIXAddress('/run/redis/redis-server.sock')
|
|
||||||
synapse.util.httpresourcetree - 56 - INFO - sentinel - Attaching <synapse.replication.http.ReplicationRestResource object at 0x7f95f850d150> to path b'/_synapse/replication'
|
|
||||||
synapse.replication.tcp.redis - 126 - INFO - sentinel - Connected to redis
|
|
||||||
synapse.replication.tcp.redis - 138 - INFO - subscribe-replication-0 - Sending redis SUBSCRIBE for ['matrix.example.com/USER_IP', 'matrix.example.com']
|
|
||||||
synapse.replication.tcp.redis - 141 - INFO - subscribe-replication-0 - Successfully subscribed to redis stream, sending REPLICATE command
|
|
||||||
synapse.replication.tcp.redis - 146 - INFO - subscribe-replication-0 - REPLICATE successfully sent
|
|
||||||
```
|
|
||||||
|
|
||||||
|
|
||||||
# Worker overview
|
# Worker overview
|
||||||
|
@ -190,18 +186,13 @@ configuration files, and then a bit of configuration for the specific worker
|
||||||
itself.
|
itself.
|
||||||
|
|
||||||
Workers need to communicate with each other and the main process, they do that
|
Workers need to communicate with each other and the main process, they do that
|
||||||
via the `replication` sockets under `/run/matrix-synapse`.
|
via the `replication` sockets under `/run/matrix-synapse` and Redis.
|
||||||
|
|
||||||
Most worker also need a way to be fed traffic by nginx, they have an `inbound`
|
Most worker also need a way to be fed traffic by nginx: they have an `inbound`
|
||||||
socket for that, in the same directory.
|
socket for that, in the same directory.
|
||||||
|
|
||||||
Finally, all those replicating workers need to be registered in the main
|
Finally, all those replicating workers need to be registered in the main
|
||||||
process: all workers and their replication sockets are listed inin the `instance_map`.
|
process: all workers and their replication sockets are listed in the `instance_map`.
|
||||||
|
|
||||||
|
|
||||||
Every worker has its own configuration file, we'll put those under
|
|
||||||
`/etc/matrix-synapse/workers`. Create it, and then one systemd service file for
|
|
||||||
all workers:
|
|
||||||
|
|
||||||
|
|
||||||
## Types of workers
|
## Types of workers
|
||||||
|
@ -223,7 +214,7 @@ We'll create the following workers:
|
||||||
* accountdata
|
* accountdata
|
||||||
* presence
|
* presence
|
||||||
* receipts
|
* receipts
|
||||||
* initial_sync: 1 and 2
|
* initial_sync: 1, 2, 3 and 4
|
||||||
* normal_sync: 1, 2 and 3
|
* normal_sync: 1, 2 and 3
|
||||||
|
|
||||||
Some of them are `stream_writers`, and the [documentation about
|
Some of them are `stream_writers`, and the [documentation about
|
||||||
|
@ -297,6 +288,8 @@ chown matrix-synapse:matrix-synapse /etc/matrix-synapse/workers
|
||||||
chmod 750 /etc/matrix-synapse-workers
|
chmod 750 /etc/matrix-synapse-workers
|
||||||
```
|
```
|
||||||
|
|
||||||
|
We'll fill this directory with `yaml` files; one for each worker.
|
||||||
|
|
||||||
|
|
||||||
### Generic worker
|
### Generic worker
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue