From 65576e82b342b1de3a95fcc69b4c80fa7183827c Mon Sep 17 00:00:00 2001 From: MiTask Date: Fri, 14 Jun 2024 08:35:54 +0000 Subject: [PATCH] Added proper shutting down --- chatBot/includes/Client.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/chatBot/includes/Client.js b/chatBot/includes/Client.js index 45f3ec7..8713fb4 100644 --- a/chatBot/includes/Client.js +++ b/chatBot/includes/Client.js @@ -15,8 +15,25 @@ class Client extends EventEmitter { this.setupSwarm(); process.on('exit', () => { + console.log('EXIT signal received. Shutting down HyperSwarm...'); this.destroy(); }); + + process.on('SIGTERM', () => { + console.log('SIGTERM signal received. Shutting down HyperSwarm...'); + this.destroy().then(() => { + console.log('HyperSwarm was shut down. Exiting the process with exit code 0.'); + process.exit(0); + }); + }); + + process.on('SIGINT', () => { + console.log('SIGINT signal received. Shutting down HyperSwarm...'); + this.destroy().then(() => { + console.log('HyperSwarm was shut down. Exiting the process with exit code 0.'); + process.exit(0); + }); + }); } setupSwarm() { -- 2.43.5