add keepalive to system config for uptime kuma monitoring
This commit is contained in:
@@ -0,0 +1,46 @@
|
|||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
config,
|
||||||
|
lib,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
let
|
||||||
|
service = "keepalive";
|
||||||
|
cfg = config.system.${service};
|
||||||
|
in {
|
||||||
|
options.system.${service} = {
|
||||||
|
enable = lib.mkEnableOption "enables ${service}";
|
||||||
|
url = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "";
|
||||||
|
description = "url to ping for uptime-kuma keepalive";
|
||||||
|
};
|
||||||
|
interval = lib.mkOption {
|
||||||
|
type = lib.types.str;
|
||||||
|
default = "60s";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
config = lib.mkIf cfg.enable {
|
||||||
|
systemd.services.keepalive = {
|
||||||
|
description = "send push for uptime kuma heartbeat";
|
||||||
|
serviceConfig = {
|
||||||
|
Type = "oneshot";
|
||||||
|
};
|
||||||
|
script = ''
|
||||||
|
${pkgs.curl}/bin/curl -fsSk \
|
||||||
|
"${cfg.url}" \
|
||||||
|
>/dev/null
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
systemd.timers.keepalive = {
|
||||||
|
wantedBy = [ "timers.target" ];
|
||||||
|
timerConfig = {
|
||||||
|
OnBootSec = "30s";
|
||||||
|
OnUnitActiveSec = cfg.interval;
|
||||||
|
Unit = "keepalive.service";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user