mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-07-13 21:50:33 +03:00
nixos/consul: add consul-alerts service
This commit is contained in:
parent
9060376bcd
commit
a17f5c8c9b
1 changed files with 46 additions and 0 deletions
|
@ -122,6 +122,34 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
alerts = {
|
||||||
|
enable = mkEnableOption "Whether to enable consul-alerts";
|
||||||
|
|
||||||
|
listenAddr = mkOption {
|
||||||
|
description = "Api listening address.";
|
||||||
|
default = "localhost:9000";
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
|
||||||
|
consulAddr = mkOption {
|
||||||
|
description = "Consul api listening adddress";
|
||||||
|
default = "localhost:8500";
|
||||||
|
type = types.str;
|
||||||
|
};
|
||||||
|
|
||||||
|
watchChecks = mkOption {
|
||||||
|
description = "Whether to enable check watcher.";
|
||||||
|
default = true;
|
||||||
|
type = types.bool;
|
||||||
|
};
|
||||||
|
|
||||||
|
watchEvents = mkOption {
|
||||||
|
description = "Whether to enable event watcher.";
|
||||||
|
default = true;
|
||||||
|
type = types.bool;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
@ -204,5 +232,23 @@ in
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
systemd.services.consul-alerts = mkIf (cfg.alerts.enable) {
|
||||||
|
wantedBy = [ "multi-user.target" ];
|
||||||
|
after = [ "consul.service" ];
|
||||||
|
|
||||||
|
path = [ pkgs.consul ];
|
||||||
|
|
||||||
|
serviceConfig = {
|
||||||
|
ExecStart = ''
|
||||||
|
${pkgs.consul-alerts}/bin/consul-alerts start \
|
||||||
|
--alert-addr=${cfg.alerts.listenAddr} \
|
||||||
|
--consul-addr=${cfg.alerts.consulAddr} \
|
||||||
|
${optionalString cfg.alerts.watchChecks "--watch-checks"} \
|
||||||
|
${optionalString cfg.alerts.watchEvents "--watch-events"}
|
||||||
|
'';
|
||||||
|
User = if cfg.dropPrivileges then "consul" else null;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue