server.js aktualisiert
This commit is contained in:
13
server.js
13
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'}));
|
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 ║');
|
||||||
|
|||||||
Reference in New Issue
Block a user