3
0
Fork 0
forked from mirrors/nixpkgs

nixos/kresd: add .instances option

This commit is contained in:
Vladimír Čunát 2020-01-27 19:23:49 +01:00
parent ae74a0e27c
commit 02bf0557c0
No known key found for this signature in database
GPG key ID: E747DF1F9575A3AA

View file

@ -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 "