Added safe check for server monitor so it doesn't go off the rails during a network reboot.
This commit is contained in:
parent
9fb2231d76
commit
0111db5610
@ -390,7 +390,7 @@ public class RedisServerRepository implements ServerRepository
|
||||
Pipeline pipeline = jedis.pipelined();
|
||||
String setKey = concatenate("serverstatus", "minecraft", _region.toString());
|
||||
String min = "-inf";
|
||||
String max = jedis.time().get(0);
|
||||
String max = Utility.currentTimeSeconds() + "";
|
||||
|
||||
List<Response<String>> responses = new ArrayList<Response<String>>();
|
||||
for (Tuple serverName : jedis.zrangeByScoreWithScores(setKey, min, max))
|
||||
|
@ -42,6 +42,8 @@ public class ServerMonitor
|
||||
private static int _totalPlayers = 0;
|
||||
private static Region _region;
|
||||
|
||||
private static boolean _debug = false;
|
||||
|
||||
public static void main (String args[])
|
||||
{
|
||||
_region = !new File("eu.dat").exists() ? Region.US : Region.EU;
|
||||
@ -264,7 +266,7 @@ public class ServerMonitor
|
||||
int requiredJoinable = serverGroup.getRequiredJoinableServers();
|
||||
int joinableServers = serverGroup.getJoinableCount();
|
||||
int totalServers = serverGroup.getServerCount();
|
||||
int serversToAdd = Math.max(requiredTotal - totalServers, requiredJoinable - joinableServers);
|
||||
int serversToAdd = Math.max(0, Math.max(requiredTotal - totalServers, requiredJoinable - joinableServers));
|
||||
int serversToKill = (totalServers > requiredTotal && joinableServers > requiredJoinable) ? Math.min(joinableServers - requiredJoinable, serverGroup.getEmptyServers().size()) : 0;
|
||||
|
||||
// Minimum 1500 slot bufferzone
|
||||
@ -339,6 +341,9 @@ public class ServerMonitor
|
||||
|
||||
private static void killServer(final String serverName, final String serverAddress, final String message, final boolean announce)
|
||||
{
|
||||
if (_debug)
|
||||
return;
|
||||
|
||||
String cmd = "/home/mineplex/easyRemoteKillServer.sh";
|
||||
|
||||
ProcessRunner pr = new ProcessRunner(new String[] {"/bin/sh", cmd, serverAddress, serverName});
|
||||
@ -384,6 +389,9 @@ public class ServerMonitor
|
||||
{
|
||||
boolean success = false;
|
||||
|
||||
if (_debug)
|
||||
return true;
|
||||
|
||||
Process process = null;
|
||||
String cmd = "/home/mineplex/isServerOnline.sh";
|
||||
|
||||
@ -442,6 +450,9 @@ public class ServerMonitor
|
||||
|
||||
private static void startServer(final DedicatedServer serverSpace, final ServerGroup serverGroup, final int serverNum, final boolean free)
|
||||
{
|
||||
if (_debug)
|
||||
return;
|
||||
|
||||
String cmd = "/home/mineplex/easyRemoteStartServerCustom.sh";
|
||||
final String groupPrefix = serverGroup.getPrefix();
|
||||
final String serverName = serverSpace.getName();
|
||||
|
Loading…
Reference in New Issue
Block a user