Add BauSystem shutdown after 5 minutes no player or 80 percentage memory load
Dieser Commit ist enthalten in:
Ursprung
6a62dde065
Commit
0337c1eb53
@ -46,6 +46,7 @@ import org.bukkit.scheduler.BukkitTask;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
|
import java.lang.management.ManagementFactory;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import java.util.logging.Level;
|
||||||
|
|
||||||
@ -171,19 +172,27 @@ public class BauSystem extends JavaPlugin implements Listener {
|
|||||||
if (autoShutdown != null) {
|
if (autoShutdown != null) {
|
||||||
autoShutdown.cancel();
|
autoShutdown.cancel();
|
||||||
}
|
}
|
||||||
/*autoShutdown = Bukkit.getScheduler().runTaskTimer(this, () -> {
|
autoShutdown = Bukkit.getScheduler().runTaskTimer(this, new Runnable() {
|
||||||
|
int count = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (count >= 5) {
|
||||||
|
Bukkit.shutdown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
count++;
|
||||||
try {
|
try {
|
||||||
ProcessBuilder processBuilder = new ProcessBuilder("/bin/bash", "-c", "free");
|
long memorySize = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getTotalPhysicalMemorySize();
|
||||||
Process process = processBuilder.start();
|
long freeMemory = ((com.sun.management.OperatingSystemMXBean) ManagementFactory.getOperatingSystemMXBean()).getFreePhysicalMemorySize();
|
||||||
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(process.getInputStream()));
|
if ((memorySize - freeMemory) / (double) memorySize > 0.8) {
|
||||||
bufferedReader.readLine();
|
|
||||||
String s = bufferedReader.readLine();
|
|
||||||
} catch (IOException exception) {
|
|
||||||
Bukkit.shutdown();
|
Bukkit.shutdown();
|
||||||
}
|
}
|
||||||
}, 1200, 1200);*/
|
} catch (Throwable throwable) {
|
||||||
// (Runtime.getRuntime().maxMemory() - Runtime.getRuntime().freeMemory()) / Runtime.getRuntime().maxMemory() > 0.8
|
Bukkit.shutdown();
|
||||||
autoShutdown = Bukkit.getScheduler().runTaskLater(this, Bukkit::shutdown, 6000);
|
}
|
||||||
|
}
|
||||||
|
}, 1200, 1200);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren