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 03816d4e..f7ce24b2 100644 --- a/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java +++ b/Launcher/src/main/java/ru/gravit/launcher/client/ClientLauncher.java @@ -36,6 +36,8 @@ import java.nio.file.attribute.PosixFilePermission; import java.security.interfaces.RSAPublicKey; import java.util.*; +import java.util.Timer; +import java.util.concurrent.TimeUnit; public final class ClientLauncher { private static Gson gson = new Gson(); @@ -294,6 +296,7 @@ private static void launch(ClientProfile profile, Params params) throws Throwabl } private static Process process = null; + private static boolean clientStarted = false; @LauncherAPI public static Process launch( @@ -325,8 +328,7 @@ public static Process launch( assetHDir.write(output); clientHDir.write(output); } - - + clientStarted = true; } } catch (IOException e) { LogHelper.error(e); @@ -386,7 +388,27 @@ public static Process launch( } // Let's rock! process = builder.start(); - if(!LogHelper.isDebugEnabled()) Thread.sleep(3000); //даем время потоку записи + if(!LogHelper.isDebugEnabled()) { + for(int i=0;i<50;++i) + { + if(!process.isAlive()) + { + int exitCode = process.exitValue(); + LogHelper.error("Process exit code %d", exitCode); + break; + } + if(clientStarted) + { + break; + } + Thread.sleep(200); + } + if(!clientStarted) + { + LogHelper.error("Write Client Params not successful. Using debug mode for more information"); + } + } + clientStarted = false; return process; }