ipfs: optionally manage ulimit -n in serviceConfig

This commit is contained in:
Eric Litak
2017-08-30 08:17:34 -07:00
parent 5f9bad6ceb
commit 952424217b
@@ -8,6 +8,7 @@ let
cfg = config.services.ipfs; cfg = config.services.ipfs;
ipfsFlags = toString ([ ipfsFlags = toString ([
(optionalString (cfg.serviceFdlimit != null) "--manage-fdlimit=true")
(optionalString cfg.autoMount "--mount") (optionalString cfg.autoMount "--mount")
(optionalString cfg.autoMigrate "--migrate") (optionalString cfg.autoMigrate "--migrate")
(optionalString cfg.enableGC "--enable-gc") (optionalString cfg.enableGC "--enable-gc")
@@ -129,6 +130,15 @@ in
default = []; default = [];
}; };
serviceFdlimit = mkOption {
type = types.nullOr types.int;
default = null;
description = ''
The fdlimit for the IPFS systemd unit or `null` to have the daemon attempt to manage it.
'';
example = 256*1024;
};
}; };
}; };
@@ -219,7 +229,7 @@ in
Group = cfg.group; Group = cfg.group;
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 1; RestartSec = 1;
}; } // optionalAttrs (cfg.serviceFdlimit != null) { LimitNOFILE = cfg.serviceFdlimit; };
}; };
systemd.services.ipfs-offline = { systemd.services.ipfs-offline = {
@@ -242,7 +252,7 @@ in
Group = cfg.group; Group = cfg.group;
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 1; RestartSec = 1;
}; } // optionalAttrs (cfg.serviceFdlimit != null) { LimitNOFILE = cfg.serviceFdlimit; };
}; };
systemd.services.ipfs-norouting = { systemd.services.ipfs-norouting = {
@@ -265,7 +275,7 @@ in
Group = cfg.group; Group = cfg.group;
Restart = "on-failure"; Restart = "on-failure";
RestartSec = 1; RestartSec = 1;
}; } // optionalAttrs (cfg.serviceFdlimit != null) { LimitNOFILE = cfg.serviceFdlimit; };
}; };
}; };