nixos/hydra: add option for starman workers
This is useful for small deployments which do not need 5 spare starman workers taking 160 MB of RAM each.
This commit is contained in:
parent
5337ff6a80
commit
6cd7477733
1 changed files with 31 additions and 3 deletions
|
@ -178,6 +178,24 @@ in
|
||||||
description = lib.mdDoc "Whether to run the server in debug mode.";
|
description = lib.mdDoc "Whether to run the server in debug mode.";
|
||||||
};
|
};
|
||||||
|
|
||||||
|
maxServers = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 25;
|
||||||
|
description = lib.mdDoc "Maximum number of starman workers to spawn.";
|
||||||
|
};
|
||||||
|
|
||||||
|
minSpareServers = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 4;
|
||||||
|
description = lib.mdDoc "Minimum number of spare starman workers to keep.";
|
||||||
|
};
|
||||||
|
|
||||||
|
maxSpareServers = mkOption {
|
||||||
|
type = types.int;
|
||||||
|
default = 5;
|
||||||
|
description = lib.mdDoc "Maximum number of spare starman workers to keep.";
|
||||||
|
};
|
||||||
|
|
||||||
extraConfig = mkOption {
|
extraConfig = mkOption {
|
||||||
type = types.lines;
|
type = types.lines;
|
||||||
description = lib.mdDoc "Extra lines for the Hydra configuration.";
|
description = lib.mdDoc "Extra lines for the Hydra configuration.";
|
||||||
|
@ -224,6 +242,16 @@ in
|
||||||
###### implementation
|
###### implementation
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
|
assertions = [
|
||||||
|
{
|
||||||
|
assertion = cfg.maxServers != 0 && cfg.maxSpareServers != 0 && cfg.minSpareServers != 0;
|
||||||
|
message = "services.hydra.{minSpareServers,maxSpareServers,minSpareServers} cannot be 0";
|
||||||
|
}
|
||||||
|
{
|
||||||
|
assertion = cfg.minSpareServers < cfg.maxSpareServers;
|
||||||
|
message = "services.hydra.minSpareServers cannot be bigger than servives.hydra.maxSpareServers";
|
||||||
|
}
|
||||||
|
];
|
||||||
|
|
||||||
users.groups.hydra = {
|
users.groups.hydra = {
|
||||||
gid = config.ids.gids.hydra;
|
gid = config.ids.gids.hydra;
|
||||||
|
@ -258,7 +286,7 @@ in
|
||||||
using_frontend_proxy = 1
|
using_frontend_proxy = 1
|
||||||
base_uri = ${cfg.hydraURL}
|
base_uri = ${cfg.hydraURL}
|
||||||
notification_sender = ${cfg.notificationSender}
|
notification_sender = ${cfg.notificationSender}
|
||||||
max_servers = 25
|
max_servers = ${toString cfg.maxServers}
|
||||||
${optionalString (cfg.logo != null) ''
|
${optionalString (cfg.logo != null) ''
|
||||||
hydra_logo = ${cfg.logo}
|
hydra_logo = ${cfg.logo}
|
||||||
''}
|
''}
|
||||||
|
@ -359,8 +387,8 @@ in
|
||||||
serviceConfig =
|
serviceConfig =
|
||||||
{ ExecStart =
|
{ ExecStart =
|
||||||
"@${hydra-package}/bin/hydra-server hydra-server -f -h '${cfg.listenHost}' "
|
"@${hydra-package}/bin/hydra-server hydra-server -f -h '${cfg.listenHost}' "
|
||||||
+ "-p ${toString cfg.port} --max_spare_servers 5 --max_servers 25 "
|
+ "-p ${toString cfg.port} --min_spare_servers ${toString cfg.minSpareServers} --max_spare_servers ${toString cfg.maxSpareServers} "
|
||||||
+ "--max_requests 100 ${optionalString cfg.debugServer "-d"}";
|
+ "--max_servers ${toString cfg.maxServers} --max_requests 100 ${optionalString cfg.debugServer "-d"}";
|
||||||
User = "hydra-www";
|
User = "hydra-www";
|
||||||
PermissionsStartOnly = true;
|
PermissionsStartOnly = true;
|
||||||
Restart = "always";
|
Restart = "always";
|
||||||
|
|
Loading…
Reference in a new issue