From bac74a7d4fd5398ab76fc50fbae96c9777b103ea Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 3 Jan 2019 21:22:59 +0700 Subject: [PATCH 1/3] =?UTF-8?q?=D0=A4=D0=B8=D0=BA=D1=81=D1=8B=20ServerWrap?= =?UTF-8?q?per?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../main/java/ru/gravit/launcher/server/ServerWrapper.java | 4 +++- modules | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java index e42b62a7..8fcdeada 100644 --- a/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/ru/gravit/launcher/server/ServerWrapper.java @@ -87,6 +87,7 @@ public static void main(String[] args) throws Throwable { modulesManager.preInitModules(); LogHelper.debug("Read ServerWrapperConfig.json"); gsonBuiler = new GsonBuilder(); + gsonBuiler.setPrettyPrinting(); gson = gsonBuiler.create(); generateConfigIfNotExists(); try(Reader reader = IOHelper.newReader(configFile)) @@ -99,7 +100,7 @@ public static void main(String[] args) throws Throwable { else CommonHelper.newThread("Server Auth Thread", true, () -> ServerWrapper.loopAuth(wrapper, config.reconnectCount, config.reconnectSleep)); modulesManager.initModules(); - String classname = config.mainclass.isEmpty() ? args[0] : config.mainclass; + String classname = (config.mainclass == null || config.mainclass.isEmpty()) ? args[0] : config.mainclass; if (classname.length() == 0) { LogHelper.error("MainClass not found. Please set MainClass for ServerWrapper.cfg or first commandline argument"); } @@ -152,6 +153,7 @@ private static void generateConfigIfNotExists() throws IOException { newConfig.port = 7240; newConfig.login = "login"; newConfig.password = "password"; + newConfig.mainclass = ""; //try(Reader reader = IOHelper.newReader(IOHelper.getResourceURL("ru/gravit/launcher/server/ServerWrapper.cfg"))) //{ // newConfig = gson.fromJson(reader,Config.class); diff --git a/modules b/modules index ec143160..eec958f2 160000 --- a/modules +++ b/modules @@ -1 +1 @@ -Subproject commit ec1431605c4951ace5cbd2ab392b67cea25bddd5 +Subproject commit eec958f2c5edbc7c053686ab7cebaab8dbca2778 From baaf2ec74e7f3aa2281cd5519139c23f4e7bf85d Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 3 Jan 2019 21:26:54 +0700 Subject: [PATCH 2/3] =?UTF-8?q?STACKTRACE=5FPROPERTY=20=D0=BA=D0=BE=D1=80?= =?UTF-8?q?=D1=80=D0=B5=D0=BA=D1=82=D0=BD=D0=BE=20=D0=BF=D0=B5=D1=80=D0=B5?= =?UTF-8?q?=D0=B4=D0=B0=D0=B5=D1=82=D1=81=D1=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java | 1 + .../src/main/java/ru/gravit/launcher/client/ClientLauncher.java | 1 + 2 files changed, 2 insertions(+) diff --git a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java index 932dc823..c8b4c21f 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java +++ b/Launcher/src/main/java/ru/gravit/launcher/ClientLauncherWrapper.java @@ -30,6 +30,7 @@ public static void main(String[] arguments) throws IOException, InterruptedExcep args.add(javaBin.toString()); String pathLauncher = IOHelper.getCodeSource(ClientLauncher.class).toString(); args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled()))); + args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled()))); Collections.addAll(args, "-javaagent:".concat(pathLauncher)); Collections.addAll(args, "-cp"); Collections.addAll(args, pathLauncher); diff --git a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java index ed888a74..e61306d3 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -358,6 +358,7 @@ public static Process launch( args.add("-Xmx" + params.ram + 'M'); } args.add(JVMHelper.jvmProperty(LogHelper.DEBUG_PROPERTY, Boolean.toString(LogHelper.isDebugEnabled()))); + args.add(JVMHelper.jvmProperty(LogHelper.STACKTRACE_PROPERTY, Boolean.toString(LogHelper.isStacktraceEnabled()))); if (LauncherConfig.ADDRESS_OVERRIDE != null) args.add(JVMHelper.jvmProperty(LauncherConfig.ADDRESS_OVERRIDE_PROPERTY, LauncherConfig.ADDRESS_OVERRIDE)); if (JVMHelper.OS_TYPE == OS.MUSTDIE) { From e525842d24dd695b1a97db6c8d3e2795ed85d302 Mon Sep 17 00:00:00 2001 From: Gravit Date: Thu, 3 Jan 2019 21:31:26 +0700 Subject: [PATCH 3/3] =?UTF-8?q?=D0=9A=D0=BE=D0=BC=D0=B0=D0=BD=D0=B4=D0=B0?= =?UTF-8?q?=20debug=20=D0=B4=D0=BB=D1=8F=20stacktrace?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/ru/gravit/launchserver/LaunchServer.java | 1 - .../launchserver/command/basic/DebugCommand.java | 13 ++++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java index 58237d2b..88af9d57 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/LaunchServer.java @@ -374,7 +374,6 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException { modulesManager.autoload(dir.resolve("modules")); modulesManager.preInitModules(); initGson(); - LogHelper.setStacktraceEnabled(true); // Read LaunchServer config generateConfigIfNotExists(); diff --git a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java index 19adc8b6..89c6a12a 100644 --- a/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java +++ b/LaunchServer/src/main/java/ru/gravit/launchserver/command/basic/DebugCommand.java @@ -11,22 +11,29 @@ public DebugCommand(LaunchServer server) { @Override public String getArgsDescription() { - return "[true/false]"; + return "[true/false] (true/false)"; } @Override public String getUsageDescription() { - return "Enable or disable debug logging at runtime"; + return "Enable or disable debug and stacktrace logging at runtime"; } @Override public void invoke(String... args) { - boolean newValue; + boolean newValue, newTraceValue; if (args.length >= 1) { newValue = Boolean.parseBoolean(args[0]); + if(args.length >= 2) newTraceValue = Boolean.parseBoolean(args[1]); + else newTraceValue = newValue; LogHelper.setDebugEnabled(newValue); + LogHelper.setStacktraceEnabled(newTraceValue); } else + { newValue = LogHelper.isDebugEnabled(); + newTraceValue = LogHelper.isStacktraceEnabled(); + } LogHelper.subInfo("Debug enabled: " + newValue); + LogHelper.subInfo("Stacktrace enabled: " + newTraceValue); } }