From 13bc29f04e3fd7cdbbfb09b1815400648eb31fb2 Mon Sep 17 00:00:00 2001 From: Joerg Behrmann Date: Fri, 19 Aug 2022 16:15:50 +0200 Subject: [PATCH] Ship worker-enabled services files by default --- .../matrix-synapse-worker@.service | 2 +- debian/matrix-synapse.service | 7 +++++- .../system => debian}/matrix-synapse.target | 0 debian/rules | 1 + docs/systemd-with-workers/README.md | 18 +++------------ .../system/matrix-synapse.service | 22 ------------------- 6 files changed, 11 insertions(+), 39 deletions(-) rename {docs/systemd-with-workers/system => debian}/matrix-synapse-worker@.service (92%) rename {docs/systemd-with-workers/system => debian}/matrix-synapse.target (100%) delete mode 100644 docs/systemd-with-workers/system/matrix-synapse.service diff --git a/docs/systemd-with-workers/system/matrix-synapse-worker@.service b/debian/matrix-synapse-worker@.service similarity index 92% rename from docs/systemd-with-workers/system/matrix-synapse-worker@.service rename to debian/matrix-synapse-worker@.service index 8f5c44c9d4ef..5515f7377e8e 100644 --- a/docs/systemd-with-workers/system/matrix-synapse-worker@.service +++ b/debian/matrix-synapse-worker@.service @@ -6,7 +6,7 @@ AssertPathExists=/etc/matrix-synapse/workers/%i.yaml PartOf=matrix-synapse.target ReloadPropagatedFrom=matrix-synapse.target -# if this is started at the same time as the main, let the main process start +# If this is started at the same time as the main, let the main process start # first, to initialise the database schema. After=matrix-synapse.service diff --git a/debian/matrix-synapse.service b/debian/matrix-synapse.service index bde1c6cb9fd9..a68a0bbd5d4c 100644 --- a/debian/matrix-synapse.service +++ b/debian/matrix-synapse.service @@ -1,8 +1,13 @@ [Unit] Description=Synapse Matrix homeserver +# This service should be restarted when the synapse target is restarted. +PartOf=matrix-synapse.target +ReloadPropagatedFrom=matrix-synapse.target + [Service] Type=notify +NotifyAccess=main User=matrix-synapse WorkingDirectory=/var/lib/matrix-synapse EnvironmentFile=-/etc/default/matrix-synapse @@ -14,4 +19,4 @@ RestartSec=3 SyslogIdentifier=matrix-synapse [Install] -WantedBy=multi-user.target +WantedBy=matrix-synapse.target diff --git a/docs/systemd-with-workers/system/matrix-synapse.target b/debian/matrix-synapse.target similarity index 100% rename from docs/systemd-with-workers/system/matrix-synapse.target rename to debian/matrix-synapse.target diff --git a/debian/rules b/debian/rules index cc73fd387cdb..1ea55824a85a 100755 --- a/debian/rules +++ b/debian/rules @@ -8,6 +8,7 @@ PACKAGE_NAME:=`dh_listpackages` override_dh_installsystemd: dh_installsystemd --name=matrix-synapse + dh_installsystemd --no-enable --name=matrix-synapse-worker@ matrix-synapse-worker@.service # we don't really want to strip the symbols from our object files. override_dh_strip: diff --git a/docs/systemd-with-workers/README.md b/docs/systemd-with-workers/README.md index d516501085bf..1cb2e78293f8 100644 --- a/docs/systemd-with-workers/README.md +++ b/docs/systemd-with-workers/README.md @@ -1,13 +1,8 @@ # Setting up Synapse with Workers and Systemd -This is a setup for managing synapse with systemd, including support for -managing workers. It provides a `matrix-synapse` service for the master, as -well as a `matrix-synapse-worker@` service template for any workers you -require. Additionally, to group the required services, it sets up a -`matrix-synapse.target`. - -See the folder [system](https://github.com/matrix-org/synapse/tree/develop/docs/systemd-with-workers/system/) -for the systemd unit files. +The necessary service files are included in the Debian packaging, see +[debian](https://github.com/matrix-org/synapse/tree/develop/debian/) for the +systemd unit files. The folder [workers](https://github.com/matrix-org/synapse/tree/develop/docs/systemd-with-workers/workers/) contains an example configuration for the `generic_worker` worker. @@ -33,18 +28,11 @@ There is no need for a separate configuration file for the master process. ## Set up 1. Adjust synapse configuration files as above. -1. Copy the `*.service` and `*.target` files in [system](https://github.com/matrix-org/synapse/tree/develop/docs/systemd-with-workers/system/) -to `/etc/systemd/system`. -1. Run `systemctl daemon-reload` to tell systemd to load the new unit files. -1. Run `systemctl enable matrix-synapse.service`. This will configure the -synapse master process to be started as part of the `matrix-synapse.target` -target. 1. For each worker process to be enabled, run `systemctl enable matrix-synapse-worker@.service`. For each ``, there should be a corresponding configuration file. `/etc/matrix-synapse/workers/.yaml`. 1. Start all the synapse processes with `systemctl start matrix-synapse.target`. -1. Tell systemd to start synapse on boot with `systemctl enable matrix-synapse.target`. ## Usage diff --git a/docs/systemd-with-workers/system/matrix-synapse.service b/docs/systemd-with-workers/system/matrix-synapse.service deleted file mode 100644 index 0c73fb55fb57..000000000000 --- a/docs/systemd-with-workers/system/matrix-synapse.service +++ /dev/null @@ -1,22 +0,0 @@ -[Unit] -Description=Synapse master - -# This service should be restarted when the synapse target is restarted. -PartOf=matrix-synapse.target -ReloadPropagatedFrom=matrix-synapse.target - -[Service] -Type=notify -NotifyAccess=main -User=matrix-synapse -WorkingDirectory=/var/lib/matrix-synapse -EnvironmentFile=-/etc/default/matrix-synapse -ExecStartPre=/opt/venvs/matrix-synapse/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --generate-keys -ExecStart=/opt/venvs/matrix-synapse/bin/python -m synapse.app.homeserver --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ -ExecReload=/bin/kill -HUP $MAINPID -Restart=always -RestartSec=3 -SyslogIdentifier=matrix-synapse - -[Install] -WantedBy=matrix-synapse.target