[FEATURE] Support customJvmOptions

This commit is contained in:
Gravita 2022-03-11 15:55:54 +07:00
parent c351846a43
commit afbed1345f
3 changed files with 8 additions and 3 deletions

View file

@ -111,6 +111,7 @@ protected void initProps() {
properties.put("launcher.guardType", server.config.launcher.guardType);
properties.put("launchercore.env", server.config.env);
properties.put("launcher.memory", server.config.launcher.memoryLimit);
properties.put("launcher.customJvmOptions", server.config.launcher.customJvmOptions);
if (server.config.launcher.encryptRuntime) {
if (server.runtime.runtimeEncryptKey == null)
server.runtime.runtimeEncryptKey = SecurityHelper.randomStringToken();

View file

@ -23,9 +23,7 @@
import pro.gravit.utils.helper.JVMHelper;
import java.io.File;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.*;
public final class LaunchServerConfig {
private transient final Logger logger = LogManager.getLogger();
@ -292,6 +290,7 @@ public static class LauncherConf {
public boolean deleteTempFiles;
public boolean certificatePinning;
public boolean encryptRuntime;
public List<String> customJvmOptions = new ArrayList<>();
public int memoryLimit = 256;
}

View file

@ -20,6 +20,8 @@ public class ClientLauncherWrapper {
public static boolean waitProcess = Boolean.getBoolean(WAIT_PROCESS_PROPERTY);
@LauncherInject("launcher.memory")
public static int launcherMemoryLimit;
@LauncherInject("launcher.customJvmOptions")
public static List<String> customJvmOptions;
public static void main(String[] arguments) throws IOException, InterruptedException {
LogHelper.printVersion("Launcher");
@ -138,6 +140,9 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
if (context.memoryLimit != 0) {
args.add(String.format("-Xmx%dM", context.memoryLimit));
}
if(customJvmOptions != null) {
args.addAll(customJvmOptions);
}
args.add("-cp");
args.add(String.join(IOHelper.PLATFORM_SEPARATOR, context.classpath));
args.add(context.mainClass);