From 9accc848c4c7a73e0fc5e8d29eae02e4b6f33263 Mon Sep 17 00:00:00 2001 From: Slavi Pantaleev Date: Fri, 13 Feb 2026 12:24:51 +0200 Subject: [PATCH] Wire conditional restart for Traefik and update setup-all to force restarts MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - Traefik's service list entry now uses the `traefik_restart_necessary` variable (computed by the Traefik role) instead of hardcoded `true`, so it is only restarted when its config, systemd unit, or image changed. - `just setup-all` now passes `devture_systemd_service_manager_conditional_restart_enabled=false` to force unconditional restarts, matching its "full setup" semantics. - Document the conditional restart behavior in docs/just.md. Some benchmarks follow for `just install-service traefik -l matrix.example.com` when Traefik settings did not change and a restart is not really necessary: - Before: - total time: 56 seconds 🐌 - Traefik restarted: yes ❌ - Services that depend on Traefik restarted: yes; all of them restarted ❌ - After: - total time: 27 seconds ⚡ - Traefik restarted: no ✅ - Services that depend on Traefik restarted: no; none restarted ✅ Co-Authored-By: Claude Opus 4.6 --- docs/just.md | 10 ++++++++++ group_vars/matrix_servers | 2 +- justfile | 2 +- 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/docs/just.md b/docs/just.md index c12743b74..72e164b8c 100644 --- a/docs/just.md +++ b/docs/just.md @@ -43,3 +43,13 @@ For example, these two commands are different: The just recipe runs `ensure-matrix-users-created` and `start` tags after `install-all`, while the latter runs only `install-all` tag. The correct shortcut of the latter is `just run-tags install-all`. Such kind of difference sometimes matters. For example, when you install a Matrix server into which you will import old data (see [here](installing.md#installing-a-server-into-which-youll-import-old-data)), you are not supposed to run `just install-all` or `just setup-all`, because these commands start services immediately after installing components, which may prevent you from importing the data. + +## Conditional service restart + +When using `just install-all` or `just install-service`, only services whose configuration or container image actually changed during the playbook run will be restarted. Unchanged services are left running (or get started if they were stopped). This reduces unnecessary downtime. + +When using `just setup-all`, all services are unconditionally restarted regardless of whether changes were detected. This is appropriate for `setup-all`'s thorough "full setup" semantics. + +`just start-all` and `just start-group` always restart all targeted services, since no installation tasks run during these commands. + +This behavior is controlled by the `devture_systemd_service_manager_conditional_restart_enabled` variable (default: `true`). To force unconditional restarts during installation, pass: `just install-all --extra-vars='devture_systemd_service_manager_conditional_restart_enabled=false'` diff --git a/group_vars/matrix_servers b/group_vars/matrix_servers index b8d4d3fe1..dd1c9d389 100755 --- a/group_vars/matrix_servers +++ b/group_vars/matrix_servers @@ -886,7 +886,7 @@ devture_systemd_service_manager_services_list_auto: | ([{ 'name': (traefik_identifier + '.service'), 'priority': 250, - 'restart_necessary': true, + 'restart_necessary': (traefik_restart_necessary | bool), 'groups': ['matrix', 'traefik', 'reverse-proxies'], }] if traefik_enabled else []) + diff --git a/justfile b/justfile index dc54828fc..f457cb71a 100644 --- a/justfile +++ b/justfile @@ -53,7 +53,7 @@ install-service service *extra_args: --extra-vars=group={{ service }} {{ extra_args }} # Runs the playbook with --tags=setup-all,ensure-matrix-users-created,start and optional arguments -setup-all *extra_args: (run-tags "setup-all,ensure-matrix-users-created,start" extra_args) +setup-all *extra_args: (run-tags "setup-all,ensure-matrix-users-created,start" "--extra-vars=devture_systemd_service_manager_conditional_restart_enabled=false" extra_args) # Runs the playbook with the given list of arguments run +extra_args: