[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("launcher.guardType", server.config.launcher.guardType);
properties.put("launchercore.env", server.config.env); properties.put("launchercore.env", server.config.env);
properties.put("launcher.memory", server.config.launcher.memoryLimit); properties.put("launcher.memory", server.config.launcher.memoryLimit);
properties.put("launcher.customJvmOptions", server.config.launcher.customJvmOptions);
if (server.config.launcher.encryptRuntime) { if (server.config.launcher.encryptRuntime) {
if (server.runtime.runtimeEncryptKey == null) if (server.runtime.runtimeEncryptKey == null)
server.runtime.runtimeEncryptKey = SecurityHelper.randomStringToken(); server.runtime.runtimeEncryptKey = SecurityHelper.randomStringToken();

View file

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

View file

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