Compare commits

..

No commits in common. "66dc7cdac2e185a8e9aec104e4dbf1f90b59e4db" and "37ce0ff5bf53eb14ef039fc86071e9b18ccebdbd" have entirely different histories.

View File

@ -19,19 +19,21 @@ class Client extends EventEmitter {
this.destroy(); this.destroy();
}); });
process.on('SIGTERM', async () => { process.on('SIGTERM', () => {
console.log('SIGTERM signal received. Shutting down HyperSwarm...'); console.log('SIGTERM signal received. Shutting down HyperSwarm...');
await this.destroy() this.destroy().then(() => {
console.log('HyperSwarm was shut down. Exiting the process with exit code 0.'); console.log('HyperSwarm was shut down. Exiting the process with exit code 0.');
process.exit(0); process.exit(0);
}); });
});
process.on('SIGINT', async () => { process.on('SIGINT', () => {
console.log('SIGINT signal received. Shutting down HyperSwarm...'); console.log('SIGINT signal received. Shutting down HyperSwarm...');
await this.destroy() this.destroy().then(() => {
console.log('HyperSwarm was shut down. Exiting the process with exit code 0.'); console.log('HyperSwarm was shut down. Exiting the process with exit code 0.');
process.exit(0); process.exit(0);
}); });
});
} }
setupSwarm() { setupSwarm() {
@ -87,8 +89,8 @@ class Client extends EventEmitter {
for (const peer of peers) peer.write(data); for (const peer of peers) peer.write(data);
} }
async destroy() { destroy() {
await this.swarm.destroy(); this.swarm.destroy();
console.log(`Bot ${this.botName} disconnected.`); console.log(`Bot ${this.botName} disconnected.`);
} }
} }