diff --git a/docker-compose.yml b/docker-compose.yml index 78e1d431..de265341 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -43,6 +43,7 @@ services: POSTGRES_DB: dereth POSTGRES_USER: postgres POSTGRES_PASSWORD: "${POSTGRES_PASSWORD}" + DB_RETENTION_DAYS: 30 volumes: - timescale-data:/var/lib/postgresql/data ports: diff --git a/main.py b/main.py index 0c2a9e6b..60aa6bb6 100644 --- a/main.py +++ b/main.py @@ -171,53 +171,67 @@ AC_LOGIN_PACKET = bytes([ ]) async def check_server_health(address: str, port: int, timeout: float = 3.0) -> tuple[bool, float, int]: - """Check AC server health via UDP packet. + """Check AC server health via UDP packet with retry logic. + Retries 6 times with 5-second delays before declaring server down. Returns: (is_up, latency_ms, player_count) """ - logger.debug(f"🔍 Starting health check for {address}:{port}") - start_time = time.time() - sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) - sock.setblocking(False) + max_retries = 6 + retry_delay = 5.0 - try: - # Send login packet (same as ThwargLauncher) - await asyncio.get_event_loop().sock_sendto(sock, AC_LOGIN_PACKET, (address, port)) + for attempt in range(max_retries): + logger.debug(f"🔍 Health check attempt {attempt + 1}/{max_retries} for {address}:{port}") + start_time = time.time() + sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) + sock.setblocking(False) - # Wait for response with timeout try: - data, addr = await asyncio.wait_for( - asyncio.get_event_loop().sock_recvfrom(sock, 1024), - timeout=timeout - ) + # Send login packet (same as ThwargLauncher) + await asyncio.get_event_loop().sock_sendto(sock, AC_LOGIN_PACKET, (address, port)) - latency_ms = (time.time() - start_time) * 1000 - logger.debug(f"📥 Received response from {addr}: {len(data)} bytes, latency: {latency_ms:.1f}ms") - - # Check if valid response (support both TimeSynch 0x800000 and ConnectRequest 0x40000) - if len(data) >= 24: - flags = struct.unpack('= 24: + flags = struct.unpack(' int: """Get player count from TreeStats.net API (same as ThwargLauncher).""" diff --git a/static/style.css b/static/style.css index 1f613073..8380d171 100644 --- a/static/style.css +++ b/static/style.css @@ -38,6 +38,7 @@ body { font-family: "Segoe UI", sans-serif; background: var(--bg-main); color: var(--text); + position: relative; } .sort-buttons { @@ -1450,3 +1451,4 @@ body.noselect, body.noselect * { .regular-spell { color: #88ccff; } +