Add debug logging to Hytale player detection
All checks were successful
Deploy GSM / deploy (push) Successful in 30s

This commit is contained in:
2026-01-15 14:22:29 +01:00
parent 30a7f3edf0
commit a518bb2b7f

View File

@@ -649,44 +649,51 @@ const HYTALE_LOGS_PATH = "/opt/hytale/Server/logs";
// Get Hytale players by parsing server logs
export async function getHytalePlayers(server) {
const ssh = await getConnection(server.host, server.sshUser);
try {
const ssh = await getConnection(server.host, server.sshUser);
// Find the most recent log file
const logFileResult = await ssh.execCommand(`ls -t ${HYTALE_LOGS_PATH}/*.log 2>/dev/null | head -1`);
if (!logFileResult.stdout.trim()) {
// Find the most recent log file
const logFileResult = await ssh.execCommand(`ls -t ${HYTALE_LOGS_PATH}/*.log 2>/dev/null | head -1`);
if (!logFileResult.stdout.trim()) {
console.log('[Hytale] No log file found');
return { online: 0, players: [] };
}
const logFile = logFileResult.stdout.trim();
// Parse log for player joins and disconnects
// Join: [World|default] Player 'Alex47' joined world 'default' at location ... (UUID)
// Leave: [PlayerSystems] Removing player 'Alex47 (Alex47)' from world 'default' (UUID)
const result = await ssh.execCommand(`grep -E "\\[World\\|.*\\] Player .* joined world|\\[PlayerSystems\\] Removing player" ${logFile} 2>/dev/null | tail -200`);
const players = new Map(); // UUID -> PlayerName
const lines = result.stdout.split('\n').filter(l => l.trim());
for (const line of lines) {
// Check for player join: [World|default] Player 'Name' joined world ... (uuid)
const joinMatch = line.match(/\[World\|[^\]]+\] Player '([^']+)' joined world .* \(([a-f0-9-]+)\)/i);
if (joinMatch) {
const playerName = joinMatch[1];
const uuid = joinMatch[2];
players.set(uuid, playerName);
continue;
}
// Check for player leave: [PlayerSystems] Removing player 'Name (Name)' from world ... (uuid)
const leaveMatch = line.match(/\[PlayerSystems\] Removing player '([^']+) \([^)]+\)' from world .* \(([a-f0-9-]+)\)/i);
if (leaveMatch) {
const uuid = leaveMatch[2];
players.delete(uuid);
}
}
const playerList = Array.from(players.values());
console.log(`[Hytale] Found ${playerList.length} players: ${playerList.join(', ') || 'none'}`);
return { online: playerList.length, players: playerList };
} catch (err) {
console.error(`[Hytale] Error getting players:`, err.message);
return { online: 0, players: [] };
}
const logFile = logFileResult.stdout.trim();
// Parse log for player joins and disconnects
// Join: [World|default] Player 'Alex47' joined world 'default' at location ... (UUID)
// Leave: [PlayerSystems] Removing player 'Alex47 (Alex47)' from world 'default' (UUID)
const result = await ssh.execCommand(`grep -E "\\[World\\|.*\\] Player .* joined world|\\[PlayerSystems\\] Removing player" ${logFile} 2>/dev/null | tail -200`);
const players = new Map(); // UUID -> PlayerName
const lines = result.stdout.split('\n');
for (const line of lines) {
// Check for player join: [World|default] Player 'Name' joined world ... (uuid)
const joinMatch = line.match(/\[World\|[^\]]+\] Player '([^']+)' joined world .* \(([a-f0-9-]+)\)/i);
if (joinMatch) {
const playerName = joinMatch[1];
const uuid = joinMatch[2];
players.set(uuid, playerName);
continue;
}
// Check for player leave: [PlayerSystems] Removing player 'Name (Name)' from world ... (uuid)
const leaveMatch = line.match(/\[PlayerSystems\] Removing player '([^']+) \([^)]+\)' from world .* \(([a-f0-9-]+)\)/i);
if (leaveMatch) {
const uuid = leaveMatch[2];
players.delete(uuid);
}
}
const playerList = Array.from(players.values());
return { online: playerList.length, players: playerList };
}
export async function readHytaleConfig(server) {