From e033520ce25cc4c83651697d0fce58ba013b8e06 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Sat, 16 Sep 2023 11:27:52 +0300 Subject: [PATCH] Make Synapse worker systemd service files depend on matrix-synapse.service Many of these do depend on the Synapse master process (`matrix-synapse.service`), so it makes sense to do it. Furthermore, we're doing it so that one can stop the `matrix-synapse.service` service and have systemd cascade this into stopping all the workers as well. This is useful for easily stopping all of Synapse, so that Postgres upgrades (`--tags=upgrade-postgres`) can happen cleanly. Postgres upgrades currently stop `devture_postgres_systemd_services_to_stop_for_maintenance_list` which includes Synapse, but stopping just the master process and leaving workers running is not safe enough and sometimes leads to errors like: > ERROR: insert or update on table "event_forward_extremities" violates foreign key constraint "event_forward_extremities_event_id" With this dependency in place, stopping `matrix-synapse.service` will stop all Synapse processes. --- .../templates/synapse/systemd/matrix-synapse-worker.service.j2 | 1 + 1 file changed, 1 insertion(+) diff --git a/roles/custom/matrix-synapse/templates/synapse/systemd/matrix-synapse-worker.service.j2 b/roles/custom/matrix-synapse/templates/synapse/systemd/matrix-synapse-worker.service.j2 index 4a6a01b78..2441e4a8d 100644 --- a/roles/custom/matrix-synapse/templates/synapse/systemd/matrix-synapse-worker.service.j2 +++ b/roles/custom/matrix-synapse/templates/synapse/systemd/matrix-synapse-worker.service.j2 @@ -3,6 +3,7 @@ Description=Synapse worker ({{ matrix_synapse_worker_container_name }}) AssertPathExists={{ matrix_synapse_config_dir_path }}/{{ matrix_synapse_worker_config_file_name }} After=matrix-synapse.service +Requires=matrix-synapse.service [Service] Type=simple