nixos/prometheus-node-exporter: use socket activation
Run node_exporter with `--web.systemd-socket` and move the listen-address/port configuration into a companion `.socket` unit. Closes https://github.com/NixOS/nixpkgs/issues/510379
This commit is contained in:
@@ -39,6 +39,7 @@ in
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
||||
serviceOpts = {
|
||||
serviceConfig = {
|
||||
DynamicUser = false;
|
||||
@@ -47,7 +48,7 @@ in
|
||||
${pkgs.prometheus-node-exporter}/bin/node_exporter \
|
||||
${concatMapStringsSep " " (x: "--collector." + x) cfg.enabledCollectors} \
|
||||
${concatMapStringsSep " " (x: "--no-collector." + x) cfg.disabledCollectors} \
|
||||
--web.listen-address ${cfg.listenAddress}:${toString cfg.port} ${concatStringsSep " " cfg.extraFlags}
|
||||
--web.systemd-socket ${concatStringsSep " " cfg.extraFlags}
|
||||
'';
|
||||
RestrictAddressFamilies =
|
||||
optionals (collectorIsEnabled "logind" || collectorIsEnabled "systemd") [
|
||||
@@ -67,4 +68,8 @@ in
|
||||
ProtectHome = true;
|
||||
};
|
||||
};
|
||||
|
||||
socketOpts = {
|
||||
socketConfig.ListenStream = "${cfg.listenAddress}:${toString cfg.port}";
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user