diff --git a/matrix/synapse/workers.md b/matrix/synapse/workers.md index 2711e12..939a715 100644 --- a/matrix/synapse/workers.md +++ b/matrix/synapse/workers.md @@ -96,6 +96,7 @@ Workers are Synapse instances that perform a single job (or a set of jobs). Their configuration goes into `/etc/matrix-synapse/workers`, which we have to create first. +Create a worker for # Preparing for sockets @@ -110,3 +111,45 @@ addgroup matrix-synapse clubmatrix addgroup www-data clubmatrix ``` +Create one systemd service file for all workers: + +``` +[Unit] +Description=Synapse %i +AssertPathExists=/etc/matrix-synapse/workers/%i.yaml + +# This service should be restarted when the synapse target is restarted. +PartOf=matrix-synapse.target +ReloadPropagatedFrom=matrix-synapse.target + +# 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 + +[Service] +Type=notify +NotifyAccess=main +User=matrix-synapse +WorkingDirectory=/var/lib/matrix-synapse +EnvironmentFile=-/etc/default/matrix-synapse +ExecStart=/opt/venvs/matrix-synapse/bin/python -m synapse.app.generic_worker --config-path=/etc/matrix-synapse/homeserver.yaml --config-path=/etc/matrix-synapse/conf.d/ --config-path=/etc/matrix-synapse/workers/%i.yaml +ExecReload=/bin/kill -HUP $MAINPID +Restart=always +RestartSec=3 +SyslogIdentifier=matrix-synapse-%i + +[Install] +WantedBy=matrix-synapse.target +``` + +And create the `matrix-synapse.target`, which combines all Synapse parts into +one systemd target: + +``` +[Unit] +Description=Matrix Synapse with all its workers +After=network.target + +[Install] +WantedBy=multi-user.target +```