From a292fdb3c55bcebd7532f3c81a494ea538cc70ed Mon Sep 17 00:00:00 2001 From: Jonathan Williams Date: Mon, 12 Oct 2015 22:26:24 -0500 Subject: [PATCH] Added failsafe for ServerMonitor. --- .../mineplex/servermonitor/ServerMonitor.java | 35 ++++++++++++------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java index 6725da134..8056b8d2a 100644 --- a/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java +++ b/Plugins/Mineplex.ServerMonitor/src/mineplex/servermonitor/ServerMonitor.java @@ -312,21 +312,28 @@ public class ServerMonitor while (_processes.size() > 0) { - for (Iterator iterator = _processes.iterator(); iterator.hasNext();) + try { - ProcessRunner pr = iterator.next(); - - try + for (Iterator iterator = _processes.iterator(); iterator.hasNext();) { - pr.join(100); - } - catch (InterruptedException e) - { - e.printStackTrace(); + ProcessRunner pr = iterator.next(); + + try + { + pr.join(100); + } + catch (InterruptedException e) + { + e.printStackTrace(); + } + + if (pr.isDone()) + iterator.remove(); } - - if (pr.isDone()) - iterator.remove(); + } + catch (Exception ex) + { + ex.printStackTrace(); } if (_processes.size() > 0) @@ -342,7 +349,7 @@ public class ServerMonitor } } - if (processWaits >= 10) + if (processWaits >= 5) { log("Killing stale processes."); @@ -351,6 +358,8 @@ public class ServerMonitor iterator.next().abort(); iterator.remove(); } + + _processes.clear(); } processWaits++;