From 376fa1b76ee396122ec60437d7457959937ea84d Mon Sep 17 00:00:00 2001 From: Gravit Date: Sun, 24 Mar 2019 15:52:50 +0700 Subject: [PATCH] =?UTF-8?q?[FIX]=20=D0=98=D0=B7=D0=BC=D0=B5=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B0=20=D0=BB=D0=BE=D0=B3=D0=B8=D0=BA=D0=B0=20=D0=BE?= =?UTF-8?q?=D0=B6=D0=B8=D0=B4=D0=B0=D0=BD=D0=B8=D1=8F=20=D0=B7=D0=B0=D0=BF?= =?UTF-8?q?=D1=83=D1=81=D0=BA=D0=B0=20=D1=81=20=D0=B2=D1=8B=D0=BA=D0=BB?= =?UTF-8?q?=D1=8E=D1=87=D0=B5=D0=BD=D0=BD=D0=BE=D0=B9=20=D0=BE=D1=82=D0=BB?= =?UTF-8?q?=D0=B0=D0=B4=D0=BA=D0=BE=D0=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../launcher/client/ClientLauncher.java | 28 +++++++++++++++++-- 1 file changed, 25 insertions(+), 3 deletions(-) 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; }