From 64291af3969f07ae7628f69761e77481f0e4e7c5 Mon Sep 17 00:00:00 2001 From: DmitriyMX Date: Sun, 13 Aug 2017 20:24:02 +0300 Subject: [PATCH] =?UTF-8?q?Zond:=20=D1=81=D0=BA=D1=80=D0=B8=D0=BF=D1=82=20?= =?UTF-8?q?=D0=BF=D1=80=D0=B8=20=20=D0=BE=D1=88=D0=B8=D0=B1=D0=BA=D0=B5=20?= =?UTF-8?q?=D1=81=D1=82=D0=B0=D1=80=D1=82=D0=B0=20=D1=81=D0=B5=D1=80=D0=B2?= =?UTF-8?q?=D0=B5=D1=80=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/asys/zond/ZondCommandHandler.java | 28 +++++++++++++++++-- zond/src/main/resources/zond.properties | 3 +- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/zond/src/main/java/asys/zond/ZondCommandHandler.java b/zond/src/main/java/asys/zond/ZondCommandHandler.java index 87b9ed9..3d9f9bb 100644 --- a/zond/src/main/java/asys/zond/ZondCommandHandler.java +++ b/zond/src/main/java/asys/zond/ZondCommandHandler.java @@ -77,9 +77,32 @@ public class ZondCommandHandler implements CommandHandler { Shell.getInstance().getOutput().println(zondColored(line)); } process.waitFor(); - } catch (IOException | InterruptedException e) { + } catch (IOException e) { Shell.getInstance().getOutput() - .println(zondColored("[!] PreStart error: " + e.getMessage(), Ansi.Color.RED)); + .println(zondColored("[!] PreStart script error: " + e.getMessage(), Ansi.Color.RED)); + } catch (InterruptedException ignore) { + } + } + + private void errorStartScript() { + if (Config.getInstance().getString("cmd.errorstart").isEmpty()) + return; + + ProcessBuilder builder = new ProcessBuilder(Arrays.asList( + Config.getInstance().getString("cmd.errorstart").split(" ", 2))); + builder.redirectErrorStream(true); + try { + Process process = builder.start(); + BufferedReader br = new BufferedReader(new InputStreamReader(process.getInputStream())); + String line; + while ((line = br.readLine()) != null) { + Shell.getInstance().getOutput().println(zondColored(line, Ansi.Color.RED)); + } + process.waitFor(); + } catch (IOException e) { + Shell.getInstance().getOutput() + .println(zondColored("[!] ErrorStart script error: " + e.getMessage(), Ansi.Color.RED)); + } catch (InterruptedException ignore) { } } @@ -218,6 +241,7 @@ public class ZondCommandHandler implements CommandHandler { if (_try == 2) { Shell.getInstance().getOutput().println(zondColored("[!] Discovered the problem when starting the process", Ansi.Color.RED)); + errorStartScript(); } }; threadExec = new Thread(task, "Zond Exec"); diff --git a/zond/src/main/resources/zond.properties b/zond/src/main/resources/zond.properties index 03dc7dc..2b8cd15 100644 --- a/zond/src/main/resources/zond.properties +++ b/zond/src/main/resources/zond.properties @@ -11,4 +11,5 @@ pingmonitor.maxlost = 6 #Linux cmd.killer = kill -KILL %PID cmd.start = java -jar server.jar -cmd.prestart = echo Hello \ No newline at end of file +cmd.prestart = echo Hello +cmd.errorstart = echo Error \ No newline at end of file