Unified shutdown functions for Telnet.

This commit is contained in:
MobiusDev
2018-05-01 16:46:21 +00:00
parent af70b6bc0c
commit b3c5f24b25
39 changed files with 53 additions and 629 deletions

View File

@@ -41,7 +41,7 @@ public class ServerAbort implements ITelnetCommand
@Override
public String handle(ChannelHandlerContext ctx, String[] args)
{
Shutdown.getInstance().telnetAbort(ctx.channel().remoteAddress().toString());
Shutdown.getInstance().abort(null);
return "Server shutdown/restart aborted!";
}
}

View File

@@ -47,7 +47,7 @@ public class ServerRestart implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, true);
Shutdown.getInstance().startShutdown(null, time, true);
return "Server will restart in " + time + " seconds!";
}
}

View File

@@ -47,7 +47,7 @@ public class ServerShutdown implements ITelnetCommand
return null;
}
final int time = Integer.parseInt(args[0]);
Shutdown.getInstance().startTelnetShutdown(ctx.channel().remoteAddress().toString(), time, false);
Shutdown.getInstance().startShutdown(null, time, false);
return "Server will shutdown in " + time + " seconds!";
}
}

View File

@@ -405,7 +405,7 @@ public class GameServer
if (Config.RESTART_ON_DEADLOCK)
{
Broadcast.toAllOnlinePlayers("Server has stability issues - restarting now.");
Shutdown.getInstance().startTelnetShutdown("DeadLockDetector - Auto Restart", 60, true);
Shutdown.getInstance().startShutdown(null, 60, true);
}
});
_deadDetectThread.setDaemon(true);

View File

@@ -84,65 +84,6 @@ public class Shutdown extends Thread
Broadcast.toAllOnlinePlayers(sysm);
}
public void startTelnetShutdown(String IP, int seconds, boolean restart)
{
LOGGER.warning("IP: " + IP + " issued shutdown command. " + MODE_TEXT[_shutdownMode] + " in " + seconds + " seconds!");
_shutdownMode = restart ? GM_RESTART : GM_SHUTDOWN;
if (_shutdownMode > 0)
{
switch (seconds)
{
case 540:
case 480:
case 420:
case 360:
case 300:
case 240:
case 180:
case 120:
case 60:
case 30:
case 10:
case 5:
case 4:
case 3:
case 2:
case 1:
{
break;
}
default:
{
SendServerQuit(seconds);
}
}
}
if (_counterInstance != null)
{
_counterInstance._abort();
}
_counterInstance = new Shutdown(seconds, restart);
_counterInstance.start();
}
/**
* This function aborts a running countdown
* @param IP IP Which Issued shutdown command
*/
public void telnetAbort(String IP)
{
LOGGER.warning("IP: " + IP + " issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();
Broadcast.toAllOnlinePlayers("Server aborts " + MODE_TEXT[_shutdownMode] + " and continues normal operation!", false);
}
}
/**
* Default constructor is only used internal to create the shutdown-hook instance
*/
@@ -383,7 +324,7 @@ public class Shutdown extends Thread
*/
public void abort(L2PcInstance activeChar)
{
LOGGER.warning("GM: " + activeChar.getName() + "(" + activeChar.getObjectId() + ") issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
LOGGER.warning("GM: " + (activeChar != null ? activeChar.getName() + "(" + activeChar.getObjectId() + ") " : "") + "issued shutdown ABORT. " + MODE_TEXT[_shutdownMode] + " has been stopped!");
if (_counterInstance != null)
{
_counterInstance._abort();