Zond: скрипт при ошибке старта сервера
This commit is contained in:
@@ -77,9 +77,32 @@ public class ZondCommandHandler implements CommandHandler {
|
|||||||
Shell.getInstance().getOutput().println(zondColored(line));
|
Shell.getInstance().getOutput().println(zondColored(line));
|
||||||
}
|
}
|
||||||
process.waitFor();
|
process.waitFor();
|
||||||
} catch (IOException | InterruptedException e) {
|
} catch (IOException e) {
|
||||||
Shell.getInstance().getOutput()
|
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) {
|
if (_try == 2) {
|
||||||
Shell.getInstance().getOutput().println(zondColored("[!] Discovered the problem when starting the process", Ansi.Color.RED));
|
Shell.getInstance().getOutput().println(zondColored("[!] Discovered the problem when starting the process", Ansi.Color.RED));
|
||||||
|
errorStartScript();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
threadExec = new Thread(task, "Zond Exec");
|
threadExec = new Thread(task, "Zond Exec");
|
||||||
|
|||||||
@@ -12,3 +12,4 @@ pingmonitor.maxlost = 6
|
|||||||
cmd.killer = kill -KILL %PID
|
cmd.killer = kill -KILL %PID
|
||||||
cmd.start = java -jar server.jar
|
cmd.start = java -jar server.jar
|
||||||
cmd.prestart = echo Hello
|
cmd.prestart = echo Hello
|
||||||
|
cmd.errorstart = echo Error
|
||||||
Reference in New Issue
Block a user