From 02bf0557c0a91ff706cf15272db4a22344cbfb16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Vladim=C3=ADr=20=C4=8Cun=C3=A1t?= Date: Mon, 27 Jan 2020 19:23:49 +0100 Subject: [PATCH] nixos/kresd: add .instances option --- nixos/modules/services/networking/kresd.nix | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/networking/kresd.nix b/nixos/modules/services/networking/kresd.nix index ce16b90b9cc1..a2f91a4200bf 100644 --- a/nixos/modules/services/networking/kresd.nix +++ b/nixos/modules/services/networking/kresd.nix @@ -96,6 +96,15 @@ in { For detailed syntax see ListenStream in man systemd.socket. ''; }; + instances = mkOption { + type = types.ints.unsigned; + default = 1; + description = '' + The number of instances to start. They will be called kresd@{1,2,...}.service. + Knot Resolver uses no threads, so this is the way to scale. + You can dynamically start/stop them at will, so this is just system default. + ''; + }; # TODO: perhaps options for more common stuff like cache size or forwarding }; @@ -112,9 +121,10 @@ in { systemd.packages = [ package ]; # the units are patched inside the package a bit - systemd.targets.kresd = { + systemd.targets.kresd = { # configure units started by default wantedBy = [ "multi-user.target" ]; - wants = [ "kres-cache-gc.service" "kresd@1.service" ]; + wants = [ "kres-cache-gc.service" ] + ++ map (i: "kresd@${toString i}.service") (range 1 cfg.instances); }; systemd.services."kresd@".serviceConfig = { ExecStart = "${package}/bin/kresd --noninteractive "