From 2c3b02a6827a406cae9e90765709c52c507d7d7f Mon Sep 17 00:00:00 2001 From: softsimon Date: Tue, 22 Sep 2020 04:27:08 +0700 Subject: [PATCH] NodeJS cluster: Delay child process auto restart 10 seconds on exit. refs #108 --- backend/src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/src/index.ts b/backend/src/index.ts index e8123e95e..ec7a2d617 100644 --- a/backend/src/index.ts +++ b/backend/src/index.ts @@ -41,8 +41,8 @@ class Server { } cluster.on('exit', (worker, code, signal) => { - console.log(`Mempool Worker #${worker.process.pid} died. Restarting...`, signal || code); - cluster.fork(); + console.log(`Mempool Worker #${worker.process.pid} died. Restarting in 10 seconds...`, signal || code); + setTimeout(() => { cluster.fork(); }, 10000); }); } else { this.startServer(true);