From 083b2794df28c90b874f8cbd07739785d2d91388 Mon Sep 17 00:00:00 2001 From: Dorian Niemiec Date: Sun, 25 Aug 2024 20:45:40 +0200 Subject: [PATCH] Uncomment the code related to sending the "stop" command to workers when Ctrl+C is pressed --- src/index.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/index.js b/src/index.js index f6978e3..c3de588 100644 --- a/src/index.js +++ b/src/index.js @@ -2086,9 +2086,8 @@ if (cluster.isPrimary || cluster.isPrimary === undefined) { process.on("SIGINT", function () { if (cluster.isPrimary !== undefined) { exiting = true; - // TODO: commands - //const allWorkers = Object.keys(cluster.workers); - /*for (var i = 0; i < allWorkers.length; i++) { + const allWorkers = Object.keys(cluster.workers); + for (var i = 0; i < allWorkers.length; i++) { try { if (cluster.workers[allWorkers[i]]) { cluster.workers[allWorkers[i]].send("stop"); @@ -2096,7 +2095,7 @@ if (cluster.isPrimary || cluster.isPrimary === undefined) { } catch (err) { // Worker will crash with EPIPE anyway. } - }*/ + } } serverconsole.locmessage("Server terminated using SIGINT"); process.exit();