From 557290612d1d9d2fcd03abaf3e117ff5b5d7edd8 Mon Sep 17 00:00:00 2001 From: aristote Date: Tue, 2 Dec 2025 14:02:21 +0100 Subject: check network in services: remove restart logic --- pkgs/lib/services/default.nix | 29 ++++++++--------------------- 1 file changed, 8 insertions(+), 21 deletions(-) diff --git a/pkgs/lib/services/default.nix b/pkgs/lib/services/default.nix index 148126c..0363ecc 100644 --- a/pkgs/lib/services/default.nix +++ b/pkgs/lib/services/default.nix @@ -8,7 +8,12 @@ let name = "check-network"; runtimeInputs = [ pkgs.unixtools.ping ]; text = '' - (${lib.concatMapStringsSep " && " (host: "ping -c 1 ${host}") hosts}) || kill -s SIGUSR1 $$ + for _ in {1..5} + do + (${lib.concatMapStringsSep " && " (host: "ping -c 1 ${host}") hosts}) && exit 0 + sleep 30 + done + exit 1 ''; }; in @@ -37,42 +42,24 @@ in home.checkNetwork = { hosts, - restart ? true, + ... }: { # Check network connectivity - Unit = { - StartLimitIntervalSec = 300; - StartLimitBurst = 5; - }; Service = lib.mkMerge [ { ExecStartPre = checkNetwork hosts; } - (lib.mkIf restart { - Restart = "on-abort"; - RestartSec = 30; - RestartMode = "direct"; # dependent units will not fail - }) ]; }; checkNetwork = { hosts, - restart ? true, + ... }: { # Check network connectivity preStart = checkNetwork hosts; - unitConfig = { - StartLimitIntervalSec = 300; - StartLimitBurst = 5; - }; - serviceConfig = lib.mkIf restart { - Restart = "on-abort"; - RestartSec = 30; - RestartMode = "direct"; # dependent units will not fail - }; }; } -- cgit v1.2.3