diff options
author | Jaka Hudoklin <jakahudoklin@gmail.com> | 2015-02-12 19:15:23 +0100 |
---|---|---|
committer | Jaka Hudoklin <jakahudoklin@gmail.com> | 2015-02-12 19:16:50 +0100 |
commit | a17f5c8c9bfa58a9bdd578971b13d2aa1b2024d1 (patch) | |
tree | 033342474b17ffa84649425eb8e627eab6cd286b /nixos | |
parent | 9060376bcde5a023b14d80c7bfdb25f5aeabb57f (diff) | |
download | nixpkgs-a17f5c8c9bfa58a9bdd578971b13d2aa1b2024d1.tar nixpkgs-a17f5c8c9bfa58a9bdd578971b13d2aa1b2024d1.tar.gz nixpkgs-a17f5c8c9bfa58a9bdd578971b13d2aa1b2024d1.tar.bz2 nixpkgs-a17f5c8c9bfa58a9bdd578971b13d2aa1b2024d1.tar.lz nixpkgs-a17f5c8c9bfa58a9bdd578971b13d2aa1b2024d1.tar.xz nixpkgs-a17f5c8c9bfa58a9bdd578971b13d2aa1b2024d1.tar.zst nixpkgs-a17f5c8c9bfa58a9bdd578971b13d2aa1b2024d1.zip |
nixos/consul: add consul-alerts service
Diffstat (limited to 'nixos')
-rw-r--r-- | nixos/modules/services/networking/consul.nix | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/nixos/modules/services/networking/consul.nix b/nixos/modules/services/networking/consul.nix index b2d5854fbc0..3ae010e8107 100644 --- a/nixos/modules/services/networking/consul.nix +++ b/nixos/modules/services/networking/consul.nix @@ -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; + }; + }; + }; } |