From 97db21c3c222191b963071a41ca8420b1c174f0a Mon Sep 17 00:00:00 2001 From: YI Date: Sat, 19 Oct 2024 11:14:15 +0800 Subject: [PATCH] Really always restart systemd units --- nix/home.nix | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/nix/home.nix b/nix/home.nix index daf2cb8..aa50916 100644 --- a/nix/home.nix +++ b/nix/home.nix @@ -1082,6 +1082,13 @@ in { in { TimeoutStartSec = "infinity"; Restart = "always"; + # Disable start limit. + # https://unix.stackexchange.com/questions/289629/systemd-restart-always-is-not-honored + StartLimitIntervalSec = 0; + # The first delay is approximately half a second. + RestartSteps = 20; + # 2^20s. A little over one month. + RestartSecMax = 104857; # watch and repeat parameter can't handle non-existent folders. # So we have to run unison without watch and repeat first. ExecStartPre = "-${pkgs.unison}/bin/unison ${commonArgs} %i"; @@ -1200,6 +1207,14 @@ in { }; Timer = { OnBootSec = "3min"; }; Service = { + Restart = "always"; + # Disable start limit. + # https://unix.stackexchange.com/questions/289629/systemd-restart-always-is-not-honored + StartLimitIntervalSec = 0; + # The first delay is approximately half a second. + RestartSteps = 20; + # 2^20s. A little over one month. + RestartSecMax = 104857; # It is ok to pass a non-existent key file. Ssh will warn us, but won't panic. ExecStart = "${pkgs.autossh}/bin/autossh -i %h/.ssh/id_ed25519_autossh $SSH_OPTIONS %i";