Fixed agent auto-shutting down servers.
This commit is contained in:
parent
cf13456e18
commit
6c7688e80a
|
@ -68,11 +68,12 @@ void startRequestedServers(ServerMetaData[] servers, AgentConfig config) {
|
|||
void checkForEmptyServers(ServerMetaData[] servers, ServerStatus[] statuses, AgentConfig config) {
|
||||
foreach (i, server; servers) {
|
||||
ServerStatus status = statuses[i];
|
||||
if (status.online && status.playersOnline > 0) {
|
||||
if (!status.online || (status.online && status.playersOnline > 0)) {
|
||||
removeIdleTrackerFileIfPresent(server);
|
||||
} else if (status.online && status.playersOnline == 0) {
|
||||
const Duration idleTime = getOrCreateIdleTrackerFileAndGetAge(server);
|
||||
if (idleTime.total!"minutes" > config.serverInactivityTimeoutMinutes) {
|
||||
writefln!"Server %s has been idle for %d minutes, shutting down."(server.name, idleTime.total!"minutes");
|
||||
stopServer(server, config);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -21,6 +21,7 @@ ServerStatus determineStatus(in ServerMetaData server) {
|
|||
int playersOnline = 0;
|
||||
string[] playerNames;
|
||||
if (online) {
|
||||
try {
|
||||
MCRconResponse response = executeRconCommand(server, "list");
|
||||
string playersList;
|
||||
int tmp;
|
||||
|
@ -33,6 +34,9 @@ ServerStatus determineStatus(in ServerMetaData server) {
|
|||
.filter!(s => s !is null && s.strip.length > 0)
|
||||
.map!(s => s.strip)
|
||||
.array;
|
||||
} catch (Exception e) {
|
||||
stderr.writefln!"Failed to get players from server: %s"(e.msg);
|
||||
}
|
||||
}
|
||||
return ServerStatus(
|
||||
server.name,
|
||||
|
|
Loading…
Reference in New Issue