Fabric API

Fabric API

108M Downloads

Fabric crashing with non 0 code breaks functionality of incrashrestarter mod

paj1s opened this issue ยท 1 comments

commented
        threadServerAliveChecker = new Thread(() -> {
            try {
                boolean lastIsRunningCheck = false;
                boolean currentIsRunningCheck;
                while (true) {
                    Thread.sleep(2000);
                    currentIsRunningCheck = Server.isRunning();
                    if (!currentIsRunningCheck && lastIsRunningCheck) {
                        AL.info("Server was stopped.");
                        if (new GeneralConfig().autoplug_auto_stop.asBoolean()) {
                            AL.info("Stopping AutoPlug too, since 'autoplug-stop' is enabled.");
                            System.exit(0);
                        } else {
                            AL.info("To stop AutoPlug too, enter '.stop both'.");
                        }

                        if (process.exitValue() != 0) {
                            if (isKill.get()) {
                                isKill.set(false);
                            } else {
                                AL.warn("Server crash was detected! Exit-Code should be 0, but is '" + process.exitValue() + "'!");
                                if (new GeneralConfig().server_restart_on_crash.asBoolean()) {
                                    AL.info("Restart on crash is enabled, thus the server is restarting...");
                                    Server.start();
                                }
                            }

                        }
                    }
                    lastIsRunningCheck = currentIsRunningCheck;
                }
            } catch (Exception e) {
                AL.error("Thread for checking if Server is alive was stopped due to an error.", e);
            }
        });
        threadServerAliveChecker.start();
commented

๐Ÿ‘‹ We use the issue tracker exclusively for final bug reports and feature requests. However, this issue appears to be better suited for either a discussion thread, or a message on our discord server. Please post your request on one of these, and the conversation can continue there.