diff --git a/server/src/main.js b/server/src/main.js index 6716af89..406c84bc 100644 --- a/server/src/main.js +++ b/server/src/main.js @@ -67,4 +67,16 @@ io.on('connection', (socket) => { socket.emit('characterList', worldEngine.getCharacterList()); }); +// ── 健康检查与运行时诊断 ────────────────────────────────────────────────────── +app.get('/healthz', (_req, res) => { + res.json({ + status: 'ok', + version: require('../package.json').version, + uptime: Math.floor(process.uptime()), + mapLoaded: worldEngine.getWorldMap() !== null, + playerCount: Object.keys(worldEngine.getAllPlayers()).length, + sseClients: sseClients.length, + }); +}); + server.listen(PORT, () => console.log(`🌍 Underworld 已启动: http://localhost:${PORT}`));