diff --git a/server.js b/server.js index 5e47346..ce8e92a 100644 --- a/server.js +++ b/server.js @@ -83,6 +83,19 @@ const server = http.createServer((req, res) => { res.writeHead(404, {'Content-Type':'application/json'}); res.end(JSON.stringify({error:'Not found'})); }); +// ── Sauberes Beenden bei SIGINT / SIGTERM (Pterodactyl Stop) ───────────────── +function shutdown(signal) { + console.log(`\n[INFO] Signal ${signal} empfangen – beende Server...`); + server.close(() => { + console.log('[INFO] Server gestoppt.'); + process.exit(0); + }); + // Fallback: nach 3s hart beenden + setTimeout(() => process.exit(0), 3000).unref(); +} +process.on('SIGINT', () => shutdown('SIGINT')); +process.on('SIGTERM', () => shutdown('SIGTERM')); + server.listen(PORT, () => { console.log('╔══════════════════════════════════════════╗'); console.log('║ GameDig Server Status API ║');