mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
[FEATURE][EXPERIMENTAL] Support debug args
This commit is contained in:
parent
d9082f21a3
commit
faa5189795
2 changed files with 28 additions and 5 deletions
|
@ -32,6 +32,7 @@
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
|
import java.nio.file.Paths;
|
||||||
import java.security.KeyPair;
|
import java.security.KeyPair;
|
||||||
import java.security.SecureRandom;
|
import java.security.SecureRandom;
|
||||||
import java.security.cert.X509Certificate;
|
import java.security.cert.X509Certificate;
|
||||||
|
@ -102,12 +103,24 @@ public static void exitLauncher(int code) {
|
||||||
forceExit(code);
|
forceExit(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean contains(String[] array, String value) {
|
||||||
|
for(String s : array) {
|
||||||
|
if(s.equals(value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String... args) throws Throwable {
|
public static void main(String... args) throws Throwable {
|
||||||
JVMHelper.checkStackTrace(LauncherEngineWrapper.class);
|
JVMHelper.checkStackTrace(LauncherEngineWrapper.class);
|
||||||
JVMHelper.verifySystemProperties(Launcher.class, true);
|
JVMHelper.verifySystemProperties(Launcher.class, true);
|
||||||
EnvHelper.checkDangerousParams();
|
EnvHelper.checkDangerousParams();
|
||||||
//if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
//if(!LauncherAgent.isStarted()) throw new SecurityException("JavaAgent not set");
|
||||||
verifyNoAgent();
|
verifyNoAgent();
|
||||||
|
if(contains(args, "--log-output") && Launcher.getConfig().environment != LauncherConfig.LauncherEnvironment.PROD) {
|
||||||
|
LogHelper.addOutput(Paths.get("Launcher.log"));
|
||||||
|
}
|
||||||
LogHelper.printVersion("Launcher");
|
LogHelper.printVersion("Launcher");
|
||||||
LogHelper.printLicense("Launcher");
|
LogHelper.printLicense("Launcher");
|
||||||
LauncherEngine.checkClass(LauncherEngineWrapper.class);
|
LauncherEngine.checkClass(LauncherEngineWrapper.class);
|
||||||
|
|
|
@ -7,10 +7,7 @@
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
public class ClientLauncherWrapper {
|
public class ClientLauncherWrapper {
|
||||||
public static final String MAGIC_ARG = "-Djdk.attach.allowAttachSelf";
|
public static final String MAGIC_ARG = "-Djdk.attach.allowAttachSelf";
|
||||||
|
@ -24,6 +21,15 @@ public class ClientLauncherWrapper {
|
||||||
public static List<String> customJvmOptions;
|
public static List<String> customJvmOptions;
|
||||||
public static RuntimeModuleManager modulesManager;
|
public static RuntimeModuleManager modulesManager;
|
||||||
|
|
||||||
|
public static boolean contains(String[] array, String value) {
|
||||||
|
for(String s : array) {
|
||||||
|
if(s.equals(value)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
public static void main(String[] arguments) throws IOException, InterruptedException {
|
public static void main(String[] arguments) throws IOException, InterruptedException {
|
||||||
LogHelper.printVersion("Launcher");
|
LogHelper.printVersion("Launcher");
|
||||||
LogHelper.printLicense("Launcher");
|
LogHelper.printLicense("Launcher");
|
||||||
|
@ -33,7 +39,6 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
LauncherConfig config = Launcher.getConfig();
|
LauncherConfig config = Launcher.getConfig();
|
||||||
modulesManager = new RuntimeModuleManager();
|
modulesManager = new RuntimeModuleManager();
|
||||||
LauncherConfig.initModules(modulesManager);
|
LauncherConfig.initModules(modulesManager);
|
||||||
|
|
||||||
LogHelper.info("Launcher for project %s", config.projectName);
|
LogHelper.info("Launcher for project %s", config.projectName);
|
||||||
if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) {
|
if (config.environment.equals(LauncherConfig.LauncherEnvironment.PROD)) {
|
||||||
if (System.getProperty(LogHelper.DEBUG_PROPERTY) != null) {
|
if (System.getProperty(LogHelper.DEBUG_PROPERTY) != null) {
|
||||||
|
@ -46,6 +51,10 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
} else {
|
} else {
|
||||||
LogHelper.info("If need debug output use -Dlauncher.debug=true");
|
LogHelper.info("If need debug output use -Dlauncher.debug=true");
|
||||||
LogHelper.info("If need stacktrace output use -Dlauncher.stacktrace=true");
|
LogHelper.info("If need stacktrace output use -Dlauncher.stacktrace=true");
|
||||||
|
if(contains(arguments, "--debug")) {
|
||||||
|
LogHelper.setDebugEnabled(true);
|
||||||
|
LogHelper.setStacktraceEnabled(true);
|
||||||
|
}
|
||||||
if (LogHelper.isDebugEnabled()) waitProcess = true;
|
if (LogHelper.isDebugEnabled()) waitProcess = true;
|
||||||
}
|
}
|
||||||
LogHelper.info("Restart Launcher with JavaAgent...");
|
LogHelper.info("Restart Launcher with JavaAgent...");
|
||||||
|
@ -104,6 +113,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep
|
||||||
context.jvmModules.add("javafx.web");
|
context.jvmModules.add("javafx.web");
|
||||||
context.args.add(MAGIC_ARG);
|
context.args.add(MAGIC_ARG);
|
||||||
context.args.add("-XX:+DisableAttachMechanism");
|
context.args.add("-XX:+DisableAttachMechanism");
|
||||||
|
context.clientArgs.addAll(Arrays.asList(arguments));
|
||||||
EnvHelper.addEnv(context.processBuilder);
|
EnvHelper.addEnv(context.processBuilder);
|
||||||
modulesManager.callWrapper(context);
|
modulesManager.callWrapper(context);
|
||||||
// ---------
|
// ---------
|
||||||
|
|
Loading…
Reference in a new issue