INNER CODE UNIT · JavaScript

shutdown

ClickDevTech/CELERITY-panel · index.js:1184

async function shutdown(signal) {
    if (isShuttingDown) return;
    isShuttingDown = true;
    logger.info(`[Server] ${signal} received, shutting down...`);
    await Promise.all(
        activeServers.map(s => new Promise(resolve => s.close(resolve)))
    );
    if (cacheService.isConnected()) {
        await cacheService.redis.quit().catch(() => {});
    }
    await mongoose.disconnect().catch(() => {});
    process.exit(0);
}

for (const sig of ['SIGTERM', 'SIGINT']) {
    process.once(sig, () => {
        setTimeout(() => process.exit(1), FORCE_SHUTDOWN_MS).unref();
        shutdown(sig).catch(() => process.exit(1));

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…