From 009815547114d0a873a10dbfe72f05ed8690c73e Mon Sep 17 00:00:00 2001 From: FragginWagon Date: Thu, 29 Jan 2026 13:19:23 +0000 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20Simplify=20arrow=20function=20synta?= =?UTF-8?q?x=20and=20remove=20unnecessary=20whitespace=20in=20graceful=20s?= =?UTF-8?q?hutdown=20utility?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../server/utils/graceful-shutdown.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/code/websites/pokedex.online/server/utils/graceful-shutdown.js b/code/websites/pokedex.online/server/utils/graceful-shutdown.js index 6965066..d419bdf 100644 --- a/code/websites/pokedex.online/server/utils/graceful-shutdown.js +++ b/code/websites/pokedex.online/server/utils/graceful-shutdown.js @@ -1,6 +1,6 @@ /** * Graceful Shutdown Handler - * + * * Handles server shutdown gracefully by: * - Closing server to stop accepting new connections * - Waiting for existing connections to finish @@ -25,7 +25,7 @@ export function setupGracefulShutdown(server, options = {}) { const connections = new Set(); // Track all connections - server.on('connection', (connection) => { + server.on('connection', connection => { connections.add(connection); connection.on('close', () => { connections.delete(connection); @@ -54,7 +54,7 @@ export function setupGracefulShutdown(server, options = {}) { // Set shutdown timeout const shutdownTimeout = setTimeout(() => { logger.error(`Shutdown timeout (${timeout}ms), forcing exit`); - connections.forEach((conn) => conn.destroy()); + connections.forEach(conn => conn.destroy()); process.exit(1); }, timeout); @@ -67,16 +67,16 @@ export function setupGracefulShutdown(server, options = {}) { // Wait for all connections to close logger.info(`Waiting for ${connections.size} connections to close...`); - + // Close all idle connections - connections.forEach((conn) => { + connections.forEach(conn => { if (!conn.destroyed) { conn.end(); } }); // Give connections time to finish - await new Promise((resolve) => { + await new Promise(resolve => { const checkInterval = setInterval(() => { if (connections.size === 0) { clearInterval(checkInterval); @@ -97,7 +97,7 @@ export function setupGracefulShutdown(server, options = {}) { // Register shutdown handlers for various signals const signals = ['SIGTERM', 'SIGINT', 'SIGUSR2']; - signals.forEach((signal) => { + signals.forEach(signal => { process.on(signal, () => shutdown(signal)); });