Compare commits
2 Commits
3b9c5635b8
...
83092b7b73
Author | SHA1 | Date | |
---|---|---|---|
83092b7b73 | |||
6805e0090d |
@ -2134,10 +2134,10 @@ Mon Aug 28 16:58:49 BST 2023
|
||||
Thu Aug 31 23:53:54 BST 2023
|
||||
|
||||
- anything else in rotuer.nix that we should servicify
|
||||
- packet forwarding
|
||||
[done] - packet forwarding
|
||||
- dhcp6 client
|
||||
- what to do with acquire-{wan,lan} scripts?
|
||||
- anything in vanilla-configuration ditto
|
||||
- [done] anything in vanilla-configuration ditto
|
||||
- packet forwarding
|
||||
- and arhcive
|
||||
- rsync
|
||||
@ -2149,3 +2149,5 @@ Thu Aug 31 23:53:54 BST 2023
|
||||
- [done] services for liminix.networking
|
||||
- [done] write a blog entry
|
||||
- [done] ntp is not setting the time
|
||||
- static dhcp(6) lease support reqd for dogfooding
|
||||
|
||||
|
@ -146,10 +146,6 @@
|
||||
NET_RALINK_SOC="y";
|
||||
SWPHY = "y";
|
||||
|
||||
WATCHDOG = "y";
|
||||
RALINK_WDT = "y"; # watchdog
|
||||
MT7621_WDT = "y"; # or it might be this one
|
||||
|
||||
GPIOLIB="y";
|
||||
GPIO_MT7621 = "y";
|
||||
|
||||
@ -162,6 +158,9 @@
|
||||
PRINTK_TIME = "y";
|
||||
} // lib.optionalAttrs (config.system.service ? vlan) {
|
||||
SWCONFIG = "y";
|
||||
} // lib.optionalAttrs (config.system.service ? watchdog) {
|
||||
RALINK_WDT = "y"; # watchdog
|
||||
MT7621_WDT = "y"; # or it might be this one
|
||||
};
|
||||
};
|
||||
};
|
||||
|
@ -29,6 +29,7 @@ in rec {
|
||||
../modules/network
|
||||
../modules/vlan
|
||||
../modules/ssh
|
||||
../modules/watchdog
|
||||
];
|
||||
|
||||
hostname = "arhcive";
|
||||
@ -67,42 +68,9 @@ in rec {
|
||||
|
||||
services.sshd = svc.ssh.build { };
|
||||
|
||||
services.watchdog =
|
||||
let
|
||||
watched = with config.services ; [ sshd dhcpc ];
|
||||
spinupGrace = 60;
|
||||
script = pkgs.writeAshScript "gaspode" {
|
||||
runtimeInputs = [ pkgs.s6 ];
|
||||
} ''
|
||||
deadline=$(expr $(date +%s) + ${toString spinupGrace})
|
||||
services=$@
|
||||
echo started feeding the dog
|
||||
exec 3> ''${WATCHDOG-/dev/watchdog}
|
||||
|
||||
healthy(){
|
||||
test $(date +%s) -le $deadline && return 0
|
||||
|
||||
for i in $services; do
|
||||
if test "$(s6-svstat -o up /run/service/$i)" != "true" ; then
|
||||
echo "service $i is down"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
while healthy ;do
|
||||
sleep 10
|
||||
echo >&3
|
||||
done
|
||||
echo "stopped feeding the dog"
|
||||
sleep 6000 # don't want s6-rc to restart
|
||||
'';
|
||||
in longrun {
|
||||
name = "watchdog";
|
||||
run =
|
||||
"${script} ${lib.concatStringsSep " " (builtins.map (s: s.name) watched)}";
|
||||
};
|
||||
|
||||
services.watchdog = svc.watchdog.build {
|
||||
watched = with config.services ; [ sshd dhcpc ];
|
||||
};
|
||||
|
||||
services.resolvconf = oneshot rec {
|
||||
dependencies = [ services.dhcpc ];
|
||||
|
@ -76,7 +76,7 @@ in rec {
|
||||
};
|
||||
|
||||
services.int = svc.network.address.build {
|
||||
interface = svc.bridge.primary.build { ifname = "int"; };# services.int;
|
||||
interface = svc.bridge.primary.build { ifname = "int"; };
|
||||
family = "inet"; address ="10.8.0.1"; prefixLength = 16;
|
||||
};
|
||||
|
||||
|
24
modules/watchdog/default.nix
Normal file
24
modules/watchdog/default.nix
Normal file
@ -0,0 +1,24 @@
|
||||
{ lib, pkgs, config, ...}:
|
||||
let
|
||||
inherit (lib) mkOption types;
|
||||
inherit (pkgs) liminix;
|
||||
in
|
||||
{
|
||||
options = {
|
||||
system.service.watchdog = mkOption {
|
||||
type = liminix.lib.types.serviceDefn;
|
||||
};
|
||||
};
|
||||
config.system.service.watchdog = liminix.callService ./watchdog.nix {
|
||||
watched = mkOption {
|
||||
description = "services to watch";
|
||||
type = types.listOf liminix.lib.types.service;
|
||||
};
|
||||
headStart = mkOption {
|
||||
description = "delay in seconds before watchdog starts checking service health";
|
||||
default = 60;
|
||||
type = types.int;
|
||||
};
|
||||
};
|
||||
config.kernel.config.WATCHDOG = "y";
|
||||
}
|
23
modules/watchdog/gaspode.sh
Executable file
23
modules/watchdog/gaspode.sh
Executable file
@ -0,0 +1,23 @@
|
||||
#!/bin/sh
|
||||
deadline=$(expr $(date +%s) + ${HEADSTART})
|
||||
services=$@
|
||||
echo started feeding the dog
|
||||
exec 3> ${WATCHDOG-/dev/watchdog}
|
||||
|
||||
healthy(){
|
||||
test $(date +%s) -le $deadline && return 0
|
||||
|
||||
for i in $services; do
|
||||
if test "$(s6-svstat -o up /run/service/$i)" != "true" ; then
|
||||
echo "service $i is down"
|
||||
return 1
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
while healthy ;do
|
||||
sleep 10
|
||||
echo >&3
|
||||
done
|
||||
echo "stopped feeding the dog"
|
||||
sleep 6000 # don't want s6-rc to restart
|
12
modules/watchdog/watchdog.nix
Normal file
12
modules/watchdog/watchdog.nix
Normal file
@ -0,0 +1,12 @@
|
||||
{
|
||||
liminix
|
||||
, lib
|
||||
}:
|
||||
{ watched, headStart } :
|
||||
let
|
||||
inherit (liminix.services) longrun;
|
||||
in longrun {
|
||||
name = "watchdog";
|
||||
run =
|
||||
"HEADSTART=${toString headStart} ${./gaspode.sh} ${lib.concatStringsSep " " (builtins.map (s: s.name) watched)}";
|
||||
}
|
Loading…
Reference in New Issue
Block a user