Archived
0

Zond: скрипт при ошибке старта сервера

This commit is contained in:
2017-08-13 20:24:02 +03:00
parent 85fd76dde1
commit 64291af396
2 changed files with 28 additions and 3 deletions

View File

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

View File

@@ -11,4 +11,5 @@ pingmonitor.maxlost = 6
#Linux
cmd.killer = kill -KILL %PID
cmd.start = java -jar server.jar
cmd.prestart = echo Hello
cmd.prestart = echo Hello
cmd.errorstart = echo Error