matrix-docker-ansible-deploy/roles/matrix-synapse/templates/synapse/systemd/matrix-synapse-worker@.service.j2
Marcel Partap 40024e9b81 Prevent workers failing if their config doesn't exist
- cherry-pick "Ensure worker config exists in systemd service (#7528)"
  from synapse d74cdc1a42e8b487d74c214b1d0ca575429d546a:
  "check that the worker config file exists instead of silently failing."
2020-10-11 21:09:19 +02:00

31 lines
927 B
Django/Jinja

#jinja2: lstrip_blocks: "True"
# c.f. https://github.com/matrix-org/synapse/pull/4662
[Unit]
Description=Synapse Matrix Worker
AssertPathExists={{matrix_synapse_config_dir_path }}/worker.%i.yaml
After=matrix-synapse.service
BindsTo=matrix-synapse.service
[Service]
Type=simple
# Intentional delay, so that the homeserver (we likely depend on) can manage to start.
ExecStartPre=/bin/sleep 5
# systemd ftw 🤦‍♂️
# https://github.com/systemd/systemd/issues/14895#issuecomment-594123923
ExecStart=/bin/sh -c "WORKER=%i; WORKER=$${WORKER%%:*}; \
exec /usr/bin/docker exec \
--user={{ matrix_user_uid }}:{{ matrix_user_gid }} \
matrix-synapse \
python -m synapse.app.$${WORKER} -c /data/homeserver.yaml -c /data/worker.%i.yaml"
ExecStop=/usr/bin/docker exec matrix-synapse pkill -f %i
KillMode=process
Restart=always
RestartSec=10
SyslogIdentifier=matrix-synapse-%i
[Install]
WantedBy=matrix-synapse.service