fixed server stopping issue

This commit is contained in:
Jonas_Jones 2023-09-03 13:16:42 +02:00
parent 5a765e32a7
commit dcb5972eb4

View file

@ -35,25 +35,27 @@ public class McWebserver implements ModInitializer {
new Thread(() -> { new Thread(() -> {
while (true) { while (true) {
if (!mcserveractive) { if (!mcserveractive) {
LOGGER.info("LMFAFMAKONJDGOADJINGOADNGHOADNHGOADNHOADHON"); sleep(2);
try { for (int i = 0; i < 2; i++) {
TimeUnit.SECONDS.sleep(2); CUrl curl = new CUrl("http://localhost:" + WEB_PORT + "/index.html").timeout(1, 1);
} catch (InterruptedException e) { curl.exec();
throw new RuntimeException(e); sleep(1);
} }
System.out.print("curl 127.0.0.1:" + WEB_PORT); LOGGER.info("Webserver Stopped!");
CUrl curl = new CUrl("curl http://localhost:" + WEB_PORT + "/index.html");
curl.exec();
break; break;
} else { } else {
System.out.print(mcserveractive); sleep(2);
try {
TimeUnit.SECONDS.sleep(2);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
} }
} }
}).start(); }).start();
} }
private void sleep(int seconds) {
try {
TimeUnit.SECONDS.sleep(seconds);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
} }