summaryrefslogtreecommitdiff
path: root/pkgs/lib/services/default.nix
diff options
context:
space:
mode:
authoraristote <quentin.aristote@irif.fr>2025-12-02 14:02:21 +0100
committeraristote <quentin.aristote@irif.fr>2025-12-02 14:11:45 +0100
commit557290612d1d9d2fcd03abaf3e117ff5b5d7edd8 (patch)
tree0ecfe00a97f2822b8faf5b4b60954733e2dc7732 /pkgs/lib/services/default.nix
parent1a896f26ce4df0eb3c5fe2f0906cc250ae2bad32 (diff)
check network in services: remove restart logic
Diffstat (limited to 'pkgs/lib/services/default.nix')
-rw-r--r--pkgs/lib/services/default.nix29
1 files 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
- };
};
}