Merge pull request #6317 from offlinehacker/nixos/consul/alerts

nixos/consul: add consul-alerts service
This commit is contained in:
Jaka Hudoklin 2015-02-12 21:39:09 +00:00
commit 2f2d638d38

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