Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • maunium/synapse
  • leytilera/synapse
2 results
Show changes
Showing
with 1357 additions and 608 deletions
Fix a performance issue introduced in Synapse v1.83.0 which meant that purging rooms was very slow and database-intensive.
\ No newline at end of file
Speed up background jobs `populate_full_user_id_user_filters` and `populate_full_user_id_profiles`.
\ No newline at end of file
#!/usr/bin/env python #!/usr/bin/env python
#
# This file is licensed under the Affero General Public License (AGPL) version 3.
#
# Copyright 2014-2016 OpenMarket Ltd # Copyright 2014-2016 OpenMarket Ltd
# Copyright (C) 2023 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Originally licensed under the Apache License, Version 2.0:
# you may not use this file except in compliance with the License. # <http://www.apache.org/licenses/LICENSE-2.0>.
# You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0 # [This file includes modifications made by New Vector Limited]
# #
# Unless required by applicable law or agreed to in writing, software #
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. """Starts a synapse client console."""
# See the License for the specific language governing permissions and
# limitations under the License.
""" Starts a synapse client console. """
import argparse import argparse
import binascii import binascii
import cmd import cmd
...@@ -237,7 +245,7 @@ class SynapseCmd(cmd.Cmd): ...@@ -237,7 +245,7 @@ class SynapseCmd(cmd.Cmd):
if "flows" not in json_res: if "flows" not in json_res:
print("Failed to find any login flows.") print("Failed to find any login flows.")
defer.returnValue(False) return False
flow = json_res["flows"][0] # assume first is the one we want. flow = json_res["flows"][0] # assume first is the one we want.
if "type" not in flow or "m.login.password" != flow["type"] or "stages" in flow: if "type" not in flow or "m.login.password" != flow["type"] or "stages" in flow:
...@@ -246,8 +254,8 @@ class SynapseCmd(cmd.Cmd): ...@@ -246,8 +254,8 @@ class SynapseCmd(cmd.Cmd):
"Unable to login via the command line client. Please visit " "Unable to login via the command line client. Please visit "
"%s to login." % fallback_url "%s to login." % fallback_url
) )
defer.returnValue(False) return False
defer.returnValue(True) return True
def do_emailrequest(self, line): def do_emailrequest(self, line):
"""Requests the association of a third party identifier """Requests the association of a third party identifier
...@@ -769,7 +777,7 @@ def main(server_url, identity_server_url, username, token, config_path): ...@@ -769,7 +777,7 @@ def main(server_url, identity_server_url, username, token, config_path):
global CONFIG_JSON global CONFIG_JSON
CONFIG_JSON = config_path # bit cheeky, but just overwrite the global CONFIG_JSON = config_path # bit cheeky, but just overwrite the global
try: try:
with open(config_path, "r") as config: with open(config_path) as config:
syn_cmd.config = json.load(config) syn_cmd.config = json.load(config)
try: try:
http_client.verbose = "on" == syn_cmd.config["verbose"] http_client.verbose = "on" == syn_cmd.config["verbose"]
......
#
# This file is licensed under the Affero General Public License (AGPL) version 3.
#
# Copyright 2014-2016 OpenMarket Ltd # Copyright 2014-2016 OpenMarket Ltd
# Copyright (C) 2023 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # Originally licensed under the Apache License, Version 2.0:
# you may not use this file except in compliance with the License. # <http://www.apache.org/licenses/LICENSE-2.0>.
# You may obtain a copy of the License at #
# [This file includes modifications made by New Vector Limited]
# #
# http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import json import json
import urllib import urllib
...@@ -37,7 +44,6 @@ class HttpClient: ...@@ -37,7 +44,6 @@ class HttpClient:
Deferred: Succeeds when we get a 2xx HTTP response. The result Deferred: Succeeds when we get a 2xx HTTP response. The result
will be the decoded JSON body. will be the decoded JSON body.
""" """
pass
def get_json(self, url, args=None): def get_json(self, url, args=None):
"""Gets some json from the given host homeserver and path """Gets some json from the given host homeserver and path
...@@ -53,7 +59,6 @@ class HttpClient: ...@@ -53,7 +59,6 @@ class HttpClient:
Deferred: Succeeds when we get a 2xx HTTP response. The result Deferred: Succeeds when we get a 2xx HTTP response. The result
will be the decoded JSON body. will be the decoded JSON body.
""" """
pass
class TwistedHttpClient(HttpClient): class TwistedHttpClient(HttpClient):
...@@ -73,7 +78,7 @@ class TwistedHttpClient(HttpClient): ...@@ -73,7 +78,7 @@ class TwistedHttpClient(HttpClient):
url, data, headers_dict={"Content-Type": ["application/json"]} url, data, headers_dict={"Content-Type": ["application/json"]}
) )
body = yield readBody(response) body = yield readBody(response)
defer.returnValue((response.code, body)) return response.code, body
@defer.inlineCallbacks @defer.inlineCallbacks
def get_json(self, url, args=None): def get_json(self, url, args=None):
...@@ -83,7 +88,7 @@ class TwistedHttpClient(HttpClient): ...@@ -83,7 +88,7 @@ class TwistedHttpClient(HttpClient):
url = "%s?%s" % (url, qs) url = "%s?%s" % (url, qs)
response = yield self._create_get_request(url) response = yield self._create_get_request(url)
body = yield readBody(response) body = yield readBody(response)
defer.returnValue(json.loads(body)) return json.loads(body)
def _create_put_request(self, url, json_data, headers_dict: Optional[dict] = None): def _create_put_request(self, url, json_data, headers_dict: Optional[dict] = None):
"""Wrapper of _create_request to issue a PUT request""" """Wrapper of _create_request to issue a PUT request"""
...@@ -129,7 +134,7 @@ class TwistedHttpClient(HttpClient): ...@@ -129,7 +134,7 @@ class TwistedHttpClient(HttpClient):
response = yield self._create_request(method, url) response = yield self._create_request(method, url)
body = yield readBody(response) body = yield readBody(response)
defer.returnValue(json.loads(body)) return json.loads(body)
@defer.inlineCallbacks @defer.inlineCallbacks
def _create_request( def _create_request(
...@@ -168,7 +173,7 @@ class TwistedHttpClient(HttpClient): ...@@ -168,7 +173,7 @@ class TwistedHttpClient(HttpClient):
if self.verbose: if self.verbose:
print("Status %s %s" % (response.code, response.phrase)) print("Status %s %s" % (response.code, response.phrase))
print(pformat(list(response.headers.getAllRawHeaders()))) print(pformat(list(response.headers.getAllRawHeaders())))
defer.returnValue(response) return response
def sleep(self, seconds): def sleep(self, seconds):
d = defer.Deferred() d = defer.Deferred()
......
...@@ -30,3 +30,6 @@ docker-compose up -d ...@@ -30,3 +30,6 @@ docker-compose up -d
### More information ### More information
For more information on required environment variables and mounts, see the main docker documentation at [/docker/README.md](../../docker/README.md) For more information on required environment variables and mounts, see the main docker documentation at [/docker/README.md](../../docker/README.md)
**For a more comprehensive Docker Compose example showcasing a full Matrix 2.0 stack, please see
https://github.com/element-hq/element-docker-demo**
\ No newline at end of file
...@@ -7,8 +7,8 @@ services: ...@@ -7,8 +7,8 @@ services:
synapse: synapse:
build: build:
context: ../.. context: ../..
dockerfile: docker/Dockerfile dockerfile: docker/Dockerfile
image: docker.io/matrixdotorg/synapse:latest image: docker.io/matrixdotorg/synapse:latest
# Since synapse does not retry to connect to the database, restart upon # Since synapse does not retry to connect to the database, restart upon
# failure # failure
...@@ -51,13 +51,13 @@ services: ...@@ -51,13 +51,13 @@ services:
- traefik.http.routers.https-synapse.tls.certResolver=le-ssl - traefik.http.routers.https-synapse.tls.certResolver=le-ssl
db: db:
image: docker.io/postgres:12-alpine image: docker.io/postgres:15-alpine
# Change that password, of course! # Change that password, of course!
environment: environment:
- POSTGRES_USER=synapse - POSTGRES_USER=synapse
- POSTGRES_PASSWORD=changeme - POSTGRES_PASSWORD=changeme
# ensure the database gets created correctly # ensure the database gets created correctly
# https://matrix-org.github.io/synapse/latest/postgres.html#set-up-database # https://element-hq.github.io/synapse/latest/postgres.html#set-up-database
- POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C - POSTGRES_INITDB_ARGS=--encoding=UTF-8 --lc-collate=C --lc-ctype=C
volumes: volumes:
# You may store the database tables in a local folder.. # You may store the database tables in a local folder..
......
...@@ -8,6 +8,9 @@ All examples and snippets assume that your Synapse service is called `synapse` i ...@@ -8,6 +8,9 @@ All examples and snippets assume that your Synapse service is called `synapse` i
An example Docker Compose file can be found [here](docker-compose.yaml). An example Docker Compose file can be found [here](docker-compose.yaml).
**For a more comprehensive Docker Compose example, showcasing a full Matrix 2.0 stack (originally based on this
docker-compose.yaml), please see https://github.com/element-hq/element-docker-demo**
## Worker Service Examples in Docker Compose ## Worker Service Examples in Docker Compose
In order to start the Synapse container as a worker, you must specify an `entrypoint` that loads both the `homeserver.yaml` and the configuration for the worker (`synapse-generic-worker-1.yaml` in the example below). You must also include the worker type in the environment variable `SYNAPSE_WORKER` or alternatively pass `-m synapse.app.generic_worker` as part of the `entrypoint` after `"/start.py", "run"`). In order to start the Synapse container as a worker, you must specify an `entrypoint` that loads both the `homeserver.yaml` and the configuration for the worker (`synapse-generic-worker-1.yaml` in the example below). You must also include the worker type in the environment variable `SYNAPSE_WORKER` or alternatively pass `-m synapse.app.generic_worker` as part of the `entrypoint` after `"/start.py", "run"`).
...@@ -69,7 +72,7 @@ redis: ...@@ -69,7 +72,7 @@ redis:
host: redis host: redis
port: 6379 port: 6379
# dbid: <redis_logical_db_id> # dbid: <redis_logical_db_id>
# password: <secret_password> # password: <secret_password>
# use_tls: True # use_tls: True
# certificate_file: <path_to_certificate> # certificate_file: <path_to_certificate>
# private_key_file: <path_to_private_key> # private_key_file: <path_to_private_key>
...@@ -113,4 +116,4 @@ federation_sender_instances: ...@@ -113,4 +116,4 @@ federation_sender_instances:
## Other Worker types ## Other Worker types
Using the concepts shown here it is possible to create other worker types in Docker Compose. See the [Workers](https://matrix-org.github.io/synapse/latest/workers.html#available-worker-applications) documentation for a list of available workers. Using the concepts shown here it is possible to create other worker types in Docker Compose. See the [Workers](https://element-hq.github.io/synapse/latest/workers.html#available-worker-applications) documentation for a list of available workers.
# Using the Synapse Grafana dashboard # Using the Synapse Grafana dashboard
0. Set up Prometheus and Grafana. Out of scope for this readme. Useful documentation about using Grafana with Prometheus: http://docs.grafana.org/features/datasources/prometheus/ 0. Set up Prometheus and Grafana. Out of scope for this readme. Useful documentation about using Grafana with Prometheus: http://docs.grafana.org/features/datasources/prometheus/
1. Have your Prometheus scrape your Synapse. https://matrix-org.github.io/synapse/latest/metrics-howto.html 1. Have your Prometheus scrape your Synapse. https://element-hq.github.io/synapse/latest/metrics-howto.html
2. Import dashboard into Grafana. Download `synapse.json`. Import it to Grafana and select the correct Prometheus datasource. http://docs.grafana.org/reference/export_import/ 2. Import dashboard into Grafana. Download `synapse.json`. Import it to Grafana and select the correct Prometheus datasource. http://docs.grafana.org/reference/export_import/
3. Set up required recording rules. [contrib/prometheus](../prometheus) 3. Set up required recording rules. [contrib/prometheus](../prometheus)
This diff is collapsed.
#
# This file is licensed under the Affero General Public License (AGPL) version 3.
#
# Copyright 2014-2016 OpenMarket Ltd # Copyright 2014-2016 OpenMarket Ltd
# Copyright (C) 2023 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.
#
# Originally licensed under the Apache License, Version 2.0:
# <http://www.apache.org/licenses/LICENSE-2.0>.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # [This file includes modifications made by New Vector Limited]
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse import argparse
import cgi
import datetime import datetime
import html
import json import json
import urllib.request import urllib.request
from typing import List from typing import List
...@@ -78,7 +85,7 @@ def make_graph(pdus: List[dict], filename_prefix: str) -> None: ...@@ -78,7 +85,7 @@ def make_graph(pdus: List[dict], filename_prefix: str) -> None:
"name": name, "name": name,
"type": pdu.get("pdu_type"), "type": pdu.get("pdu_type"),
"state_key": pdu.get("state_key"), "state_key": pdu.get("state_key"),
"content": cgi.escape(json.dumps(pdu.get("content")), quote=True), "content": html.escape(json.dumps(pdu.get("content")), quote=True),
"time": t, "time": t,
"depth": pdu.get("depth"), "depth": pdu.get("depth"),
} }
......
#
# This file is licensed under the Affero General Public License (AGPL) version 3.
#
# Copyright 2014-2016 OpenMarket Ltd # Copyright 2014-2016 OpenMarket Ltd
# Copyright (C) 2023 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.
#
# Originally licensed under the Apache License, Version 2.0:
# <http://www.apache.org/licenses/LICENSE-2.0>.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # [This file includes modifications made by New Vector Limited]
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse import argparse
......
#
# This file is licensed under the Affero General Public License (AGPL) version 3.
#
# Copyright 2016 OpenMarket Ltd # Copyright 2016 OpenMarket Ltd
# Copyright (C) 2023 New Vector, Ltd
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# See the GNU Affero General Public License for more details:
# <https://www.gnu.org/licenses/agpl-3.0.html>.
#
# Originally licensed under the Apache License, Version 2.0:
# <http://www.apache.org/licenses/LICENSE-2.0>.
# #
# Licensed under the Apache License, Version 2.0 (the "License"); # [This file includes modifications made by New Vector Limited]
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
# #
# http://www.apache.org/licenses/LICENSE-2.0
# #
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
import argparse import argparse
import datetime import datetime
......
# `lnav` config for Synapse logs # `lnav` config for Synapse logs
[lnav](https://lnav.org/) is a log-viewing tool. It is particularly useful when [lnav](https://lnav.org/) is a log-viewing tool. It is particularly useful when
you need to interleave multiple log files, or for exploring a large log file you need to interleave multiple log files, or for exploring a large log file
with regex filters. The downside is that it is not as ubiquitous as tools like with regex filters. The downside is that it is not as ubiquitous as tools like
`less`, `grep`, etc. `less`, `grep`, etc.
...@@ -9,7 +9,7 @@ This directory contains an `lnav` [log format definition]( ...@@ -9,7 +9,7 @@ This directory contains an `lnav` [log format definition](
https://docs.lnav.org/en/v0.10.1/formats.html#defining-a-new-format https://docs.lnav.org/en/v0.10.1/formats.html#defining-a-new-format
) for Synapse logs as ) for Synapse logs as
emitted by Synapse with the default [logging configuration]( emitted by Synapse with the default [logging configuration](
https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html#log_config https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html#log_config
). It supports lnav 0.10.1 because that's what's packaged by my distribution. ). It supports lnav 0.10.1 because that's what's packaged by my distribution.
This should allow lnav: This should allow lnav:
...@@ -36,12 +36,12 @@ Within lnav itself: ...@@ -36,12 +36,12 @@ Within lnav itself:
- `?` for help within lnav itself. - `?` for help within lnav itself.
- `q` to quit. - `q` to quit.
- `/` to search a-la `less` and `vim`, then `n` and `N` to continue searching - `/` to search a-la `less` and `vim`, then `n` and `N` to continue searching
down and up. down and up.
- Use `o` and `O` to skip through logs based on the request ID (`POST-1234`, or - Use `o` and `O` to skip through logs based on the request ID (`POST-1234`, or
else the value of the [`request_id_header`]( else the value of the [`request_id_header`](
https://matrix-org.github.io/synapse/latest/usage/configuration/config_documentation.html?highlight=request_id_header#listeners https://element-hq.github.io/synapse/latest/usage/configuration/config_documentation.html?highlight=request_id_header#listeners
) header). This may get confused if the same request ID is repeated among ) header). This may get confused if the same request ID is repeated among
multiple files or process restarts. multiple files or process restarts.
- ??? - ???
- Profit - Profit
...@@ -29,7 +29,7 @@ ...@@ -29,7 +29,7 @@
"level": "error" "level": "error"
}, },
{ {
"line": "my-matrix-server-federation-sender-1 | 2023-01-25 20:56:20,995 - synapse.http.matrixfederationclient - 709 - WARNING - federation_transaction_transmission_loop-3 - {PUT-O-3} [example.com] Request failed: PUT matrix://example.com/_matrix/federation/v1/send/1674680155797: HttpResponseException('403: Forbidden')", "line": "my-matrix-server-federation-sender-1 | 2023-01-25 20:56:20,995 - synapse.http.matrixfederationclient - 709 - WARNING - federation_transaction_transmission_loop-3 - {PUT-O-3} [example.com] Request failed: PUT matrix-federation://example.com/_matrix/federation/v1/send/1674680155797: HttpResponseException('403: Forbidden')",
"level": "warning" "level": "warning"
}, },
{ {
......
...@@ -34,7 +34,7 @@ Add a new job to the main prometheus.yml file: ...@@ -34,7 +34,7 @@ Add a new job to the main prometheus.yml file:
``` ```
An example of a Prometheus configuration with workers can be found in An example of a Prometheus configuration with workers can be found in
[metrics-howto.md](https://matrix-org.github.io/synapse/latest/metrics-howto.html). [metrics-howto.md](https://element-hq.github.io/synapse/latest/metrics-howto.html).
To use `synapse.rules` add To use `synapse.rules` add
......
...@@ -4,8 +4,8 @@ Purge history API examples ...@@ -4,8 +4,8 @@ Purge history API examples
# `purge_history.sh` # `purge_history.sh`
A bash file, that uses the A bash file, that uses the
[purge history API](https://matrix-org.github.io/synapse/latest/admin_api/purge_history_api.html) [purge history API](https://element-hq.github.io/synapse/latest/admin_api/purge_history_api.html)
to purge all messages in a list of rooms up to a certain event. You can select a to purge all messages in a list of rooms up to a certain event. You can select a
timeframe or a number of messages that you want to keep in the room. timeframe or a number of messages that you want to keep in the room.
Just configure the variables DOMAIN, ADMIN, ROOMS_ARRAY and TIME at the top of Just configure the variables DOMAIN, ADMIN, ROOMS_ARRAY and TIME at the top of
...@@ -14,5 +14,5 @@ the script. ...@@ -14,5 +14,5 @@ the script.
# `purge_remote_media.sh` # `purge_remote_media.sh`
A bash file, that uses the A bash file, that uses the
[purge history API](https://matrix-org.github.io/synapse/latest/admin_api/purge_history_api.html) [purge history API](https://element-hq.github.io/synapse/latest/admin_api/purge_history_api.html)
to purge all old cached remote media. to purge all old cached remote media.
#!/usr/bin/env bash #!/usr/bin/env bash
# this script will use the api: # this script will use the api:
# https://matrix-org.github.io/synapse/latest/admin_api/purge_history_api.html # https://element-hq.github.io/synapse/latest/admin_api/purge_history_api.html
# #
# It will purge all messages in a list of rooms up to a cetrain event # It will purge all messages in a list of rooms up to a cetrain event
################################################################################################### ###################################################################################################
...@@ -77,9 +77,9 @@ TOKEN=$(sql "SELECT token FROM access_tokens WHERE user_id='$ADMIN' ORDER BY id ...@@ -77,9 +77,9 @@ TOKEN=$(sql "SELECT token FROM access_tokens WHERE user_id='$ADMIN' ORDER BY id
AUTH="Authorization: Bearer $TOKEN" AUTH="Authorization: Bearer $TOKEN"
################################################################################################### ###################################################################################################
# check, if your TOKEN works. For example this works: # check, if your TOKEN works. For example this works:
################################################################################################### ###################################################################################################
# $ curl --header "$AUTH" "$API_URL/rooms/$ROOM/state/m.room.power_levels" # $ curl --header "$AUTH" "$API_URL/rooms/$ROOM/state/m.room.power_levels"
################################################################################################### ###################################################################################################
# finally start pruning the room: # finally start pruning the room:
...@@ -117,13 +117,13 @@ for ROOM in "${ROOMS_ARRAY[@]}"; do ...@@ -117,13 +117,13 @@ for ROOM in "${ROOMS_ARRAY[@]}"; do
sleep $SLEEP sleep $SLEEP
STATUS=$(curl --header "$AUTH" -s GET "$API_URL/admin/purge_history_status/$PURGE_ID" |grep status|cut -d'"' -f4) STATUS=$(curl --header "$AUTH" -s GET "$API_URL/admin/purge_history_status/$PURGE_ID" |grep status|cut -d'"' -f4)
: "$ROOM --> Status: $STATUS" : "$ROOM --> Status: $STATUS"
[[ "$STATUS" == "active" ]] || break [[ "$STATUS" == "active" ]] || break
SLEEP=$((SLEEP + 1)) SLEEP=$((SLEEP + 1))
done done
fi fi
set +x set +x
sleep 1 sleep 1
fi fi
done done
......
The documentation for using systemd to manage synapse workers is now part of The documentation for using systemd to manage synapse workers is now part of
the main synapse distribution. See the main synapse distribution. See
[docs/systemd-with-workers](https://matrix-org.github.io/synapse/latest/systemd-with-workers/index.html). [docs/systemd-with-workers](https://element-hq.github.io/synapse/latest/systemd-with-workers/index.html).
# Setup Synapse with Systemd # Setup Synapse with Systemd
This is a setup for managing synapse with a user contributed systemd unit This is a setup for managing synapse with a user contributed systemd unit
file. It provides a `matrix-synapse` systemd unit file that should be tailored file. It provides a `matrix-synapse` systemd unit file that should be tailored
to accommodate your installation in accordance with the installation to accommodate your installation in accordance with the installation
instructions provided in instructions provided in
[installation instructions](https://matrix-org.github.io/synapse/latest/setup/installation.html). [installation instructions](https://element-hq.github.io/synapse/latest/setup/installation.html).
## Setup ## Setup
1. Under the service section, ensure the `User` variable matches which user 1. Under the service section, ensure the `User` variable matches which user
you installed synapse under and wish to run it as. you installed synapse under and wish to run it as.
2. Under the service section, ensure the `WorkingDirectory` variable matches 2. Under the service section, ensure the `WorkingDirectory` variable matches
where you have installed synapse. where you have installed synapse.
3. Under the service section, ensure the `ExecStart` variable matches the 3. Under the service section, ensure the `ExecStart` variable matches the
......
# Creating multiple stream writers with a bash script # Creating multiple stream writers with a bash script
This script creates multiple [stream writer](https://github.com/matrix-org/synapse/blob/develop/docs/workers.md#stream-writers) workers. This script creates multiple [stream writer](https://github.com/element-hq/synapse/blob/develop/docs/workers.md#stream-writers) workers.
Stream writers require both replication and HTTP listeners. Stream writers require both replication and HTTP listeners.
...@@ -8,7 +8,7 @@ It also prints out the example lines for Synapse main configuration file. ...@@ -8,7 +8,7 @@ It also prints out the example lines for Synapse main configuration file.
Remember to route necessary endpoints directly to a worker associated with it. Remember to route necessary endpoints directly to a worker associated with it.
If you run the script as-is, it will create workers with the replication listener starting from port 8034 and another, regular http listener starting from 8044. If you don't need all of the stream writers listed in the script, just remove them from the ```STREAM_WRITERS``` array. If you run the script as-is, it will create workers with the replication listener starting from port 8034 and another, regular http listener starting from 8044. If you don't need all of the stream writers listed in the script, just remove them from the ```STREAM_WRITERS``` array.
Hint: Note that `worker_pid_file` is required if `worker_daemonize` is `true`. Uncomment and/or modify the line if needed. Hint: Note that `worker_pid_file` is required if `worker_daemonize` is `true`. Uncomment and/or modify the line if needed.
...@@ -71,7 +71,7 @@ cat << EXAMPLECONFIG ...@@ -71,7 +71,7 @@ cat << EXAMPLECONFIG
# Don't forget to configure your reverse proxy and # Don't forget to configure your reverse proxy and
# necessary endpoints to their respective worker. # necessary endpoints to their respective worker.
# See https://github.com/matrix-org/synapse/blob/develop/docs/workers.md # See https://github.com/element-hq/synapse/blob/develop/docs/workers.md
# for more information. # for more information.
# Remember: Under NO circumstances should the replication # Remember: Under NO circumstances should the replication
...@@ -102,7 +102,7 @@ You should receive an output similar to the following: ...@@ -102,7 +102,7 @@ You should receive an output similar to the following:
# Don't forget to configure your reverse proxy and # Don't forget to configure your reverse proxy and
# necessary endpoints to their respective worker. # necessary endpoints to their respective worker.
# See https://github.com/matrix-org/synapse/blob/develop/docs/workers.md # See https://github.com/element-hq/synapse/blob/develop/docs/workers.md
# for more information # for more information
# Remember: Under NO circumstances should the replication # Remember: Under NO circumstances should the replication
...@@ -138,14 +138,14 @@ Simply copy-and-paste the output to an appropriate place in your Synapse main co ...@@ -138,14 +138,14 @@ Simply copy-and-paste the output to an appropriate place in your Synapse main co
## Write directly to Synapse configuration file ## Write directly to Synapse configuration file
You could also write the output directly to homeserver main configuration file. **This, however, is not recommended** as even a small typo (such as replacing >> with >) can erase the entire ```homeserver.yaml```. You could also write the output directly to homeserver main configuration file. **This, however, is not recommended** as even a small typo (such as replacing >> with >) can erase the entire ```homeserver.yaml```.
If you do this, back up your original configuration file first: If you do this, back up your original configuration file first:
```console ```console
# Back up homeserver.yaml first # Back up homeserver.yaml first
cp /etc/matrix-synapse/homeserver.yaml /etc/matrix-synapse/homeserver.yaml.bak cp /etc/matrix-synapse/homeserver.yaml /etc/matrix-synapse/homeserver.yaml.bak
# Create workers and write output to your homeserver.yaml # Create workers and write output to your homeserver.yaml
./create_stream_writers.sh >> /etc/matrix-synapse/homeserver.yaml ./create_stream_writers.sh >> /etc/matrix-synapse/homeserver.yaml
``` ```