nixos/consul: add consul-alerts service

This commit is contained in:
Jaka Hudoklin 2015-02-12 19:15:23 +01:00
parent 9060376bcd
commit a17f5c8c9b

View file

@ -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;
};
};
};
}