server.js aktualisiert

This commit is contained in:
Cap
2026-02-26 13:16:09 +01:00
parent e62904dcca
commit cca63588d7

View File

@@ -83,6 +83,19 @@ const server = http.createServer((req, res) => {
res.writeHead(404, {'Content-Type':'application/json'}); res.end(JSON.stringify({error:'Not found'})); 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, () => { server.listen(PORT, () => {
console.log('╔══════════════════════════════════════════╗'); console.log('╔══════════════════════════════════════════╗');
console.log('║ GameDig Server Status API ║'); console.log('║ GameDig Server Status API ║');