feat(nixos): module: +support-bot
This commit is contained in:
71
nixos/module/hectic/service/server-health.nix
Normal file
71
nixos/module/hectic/service/server-health.nix
Normal file
@@ -0,0 +1,71 @@
|
||||
{
|
||||
inputs,
|
||||
flake,
|
||||
self,
|
||||
}:
|
||||
{
|
||||
pkgs,
|
||||
lib,
|
||||
config,
|
||||
...
|
||||
}: let
|
||||
system = pkgs.system;
|
||||
cfg = config.hectic.server-health;
|
||||
# URLS="http://..." # default: none
|
||||
# VOLUMES="/ /home" # default: all from df -P
|
||||
in {
|
||||
options = {
|
||||
hectic.server-health = {
|
||||
enable = lib.mkEnableOption "enable serverhelth services";
|
||||
urls = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = "5899";
|
||||
description = ''
|
||||
urls to check
|
||||
'';
|
||||
};
|
||||
volumes = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = "5899";
|
||||
description = ''
|
||||
volumes to check
|
||||
'';
|
||||
};
|
||||
port = lib.mkOption {
|
||||
type = lib.types.port;
|
||||
default = "5899";
|
||||
description = ''
|
||||
service's port
|
||||
'';
|
||||
};
|
||||
};
|
||||
};
|
||||
config = lib.mkIf cfg.enable {
|
||||
systemd.services."hectic-server-health" = {
|
||||
description = "Hectic server health check";
|
||||
after = [ "network.target" ];
|
||||
wantedBy = [ "multi-user.target" ];
|
||||
serviceConfig = {
|
||||
Type = "simple";
|
||||
ExecStart = "${self.packages.${system}.server-health}/bin/server-health";
|
||||
Environment = (if cfg.urls != null then [
|
||||
"URLS=${cfg.urls}"
|
||||
] else []) ++ (if cfg.volumes != null then [
|
||||
"VOLUMES=${cfg.volumes}"
|
||||
] else []);
|
||||
Restart = "always";
|
||||
RestartSec = "5s";
|
||||
|
||||
# Shutdown configuration
|
||||
TimeoutStopSec = "30s";
|
||||
KillSignal = "SIGTERM";
|
||||
KillMode = "mixed";
|
||||
|
||||
# Security and process management
|
||||
RemainAfterExit = false;
|
||||
StandardOutput = "journal";
|
||||
StandardError = "journal";
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user