unifi: add options to control JVM heap size
Our controller was acting very sluggish at times and increasing available RAM for the JVM fixes this.
This commit is contained in:
parent
3b472d78a8
commit
1075919413
@ -3,7 +3,12 @@ with lib;
|
|||||||
let
|
let
|
||||||
cfg = config.services.unifi;
|
cfg = config.services.unifi;
|
||||||
stateDir = "/var/lib/unifi";
|
stateDir = "/var/lib/unifi";
|
||||||
cmd = "@${pkgs.jre}/bin/java java -jar ${stateDir}/lib/ace.jar";
|
cmd = ''
|
||||||
|
@${pkgs.jre}/bin/java java \
|
||||||
|
${optionalString (cfg.initialJavaHeapSize != null) "-Xms${(toString cfg.initialJavaHeapSize)}m"} \
|
||||||
|
${optionalString (cfg.maximumJavaHeapSize != null) "-Xmx${(toString cfg.maximumJavaHeapSize)}m"} \
|
||||||
|
-jar ${stateDir}/lib/ace.jar
|
||||||
|
'';
|
||||||
mountPoints = [
|
mountPoints = [
|
||||||
{
|
{
|
||||||
what = "${pkgs.unifi}/dl";
|
what = "${pkgs.unifi}/dl";
|
||||||
@ -58,6 +63,26 @@ in
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
services.unifi.initialJavaHeapSize = mkOption {
|
||||||
|
type = types.nullOr types.int;
|
||||||
|
default = null;
|
||||||
|
example = 1024;
|
||||||
|
description = ''
|
||||||
|
Set the initial heap size for the JVM in MB. If this option isn't set, the
|
||||||
|
JVM will decide this value at runtime.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
|
services.unifi.maximumJavaHeapSize = mkOption {
|
||||||
|
type = types.nullOr types.int;
|
||||||
|
default = null;
|
||||||
|
example = 4096;
|
||||||
|
description = ''
|
||||||
|
Set the maximimum heap size for the JVM in MB. If this option isn't set, the
|
||||||
|
JVM will decide this value at runtime.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
config = mkIf cfg.enable {
|
config = mkIf cfg.enable {
|
||||||
@ -121,8 +146,8 @@ in
|
|||||||
|
|
||||||
serviceConfig = {
|
serviceConfig = {
|
||||||
Type = "simple";
|
Type = "simple";
|
||||||
ExecStart = "${cmd} start";
|
ExecStart = "${(removeSuffix "\n" cmd)} start";
|
||||||
ExecStop = "${cmd} stop";
|
ExecStop = "${(removeSuffix "\n" cmd)} stop";
|
||||||
User = "unifi";
|
User = "unifi";
|
||||||
PermissionsStartOnly = true;
|
PermissionsStartOnly = true;
|
||||||
UMask = "0077";
|
UMask = "0077";
|
||||||
|
Loading…
x
Reference in New Issue
Block a user