Merge remote-tracking branch 'origin/master' into patchy

This commit is contained in:
zaxar163 2019-01-03 17:15:15 +04:00
commit 68109c1ea3
No known key found for this signature in database
GPG key ID: CEE900027AE098E0
5 changed files with 15 additions and 5 deletions

View file

@ -384,7 +384,6 @@ public LaunchServer(Path dir, String[] args) throws IOException, InvalidKeySpecE
modulesManager.autoload(dir.resolve("modules"));
modulesManager.preInitModules();
initGson();
LogHelper.setStacktraceEnabled(true);
// Read LaunchServer config
generateConfigIfNotExists();

View file

@ -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);
}
}

View file

@ -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);

View file

@ -356,6 +356,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) {

View file

@ -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);