lol

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.

authored by

Simon Lackerbauer and committed by
Robin Gloster
10759194 3b472d78

+28 -3
+28 -3
nixos/modules/services/networking/unifi.nix
··· 3 3 let 4 4 cfg = config.services.unifi; 5 5 stateDir = "/var/lib/unifi"; 6 - cmd = "@${pkgs.jre}/bin/java java -jar ${stateDir}/lib/ace.jar"; 6 + cmd = '' 7 + @${pkgs.jre}/bin/java java \ 8 + ${optionalString (cfg.initialJavaHeapSize != null) "-Xms${(toString cfg.initialJavaHeapSize)}m"} \ 9 + ${optionalString (cfg.maximumJavaHeapSize != null) "-Xmx${(toString cfg.maximumJavaHeapSize)}m"} \ 10 + -jar ${stateDir}/lib/ace.jar 11 + ''; 7 12 mountPoints = [ 8 13 { 9 14 what = "${pkgs.unifi}/dl"; ··· 58 63 ''; 59 64 }; 60 65 66 + services.unifi.initialJavaHeapSize = mkOption { 67 + type = types.nullOr types.int; 68 + default = null; 69 + example = 1024; 70 + description = '' 71 + Set the initial heap size for the JVM in MB. If this option isn't set, the 72 + JVM will decide this value at runtime. 73 + ''; 74 + }; 75 + 76 + services.unifi.maximumJavaHeapSize = mkOption { 77 + type = types.nullOr types.int; 78 + default = null; 79 + example = 4096; 80 + description = '' 81 + Set the maximimum heap size for the JVM in MB. If this option isn't set, the 82 + JVM will decide this value at runtime. 83 + ''; 84 + }; 85 + 61 86 }; 62 87 63 88 config = mkIf cfg.enable { ··· 121 146 122 147 serviceConfig = { 123 148 Type = "simple"; 124 - ExecStart = "${cmd} start"; 125 - ExecStop = "${cmd} stop"; 149 + ExecStart = "${(removeSuffix "\n" cmd)} start"; 150 + ExecStop = "${(removeSuffix "\n" cmd)} stop"; 126 151 User = "unifi"; 127 152 PermissionsStartOnly = true; 128 153 UMask = "0077";