Merge pull request 'Fix shutdown' (#9) from MiTask/LinkUp-P2P-Chat:main into main
Reviewed-on: #9
This commit is contained in:
commit
66dc7cdac2
@ -19,21 +19,19 @@ class Client extends EventEmitter {
|
|||||||
this.destroy();
|
this.destroy();
|
||||||
});
|
});
|
||||||
|
|
||||||
process.on('SIGTERM', () => {
|
process.on('SIGTERM', async () => {
|
||||||
console.log('SIGTERM signal received. Shutting down HyperSwarm...');
|
console.log('SIGTERM signal received. Shutting down HyperSwarm...');
|
||||||
this.destroy().then(() => {
|
await this.destroy()
|
||||||
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', () => {
|
process.on('SIGINT', async () => {
|
||||||
console.log('SIGINT signal received. Shutting down HyperSwarm...');
|
console.log('SIGINT signal received. Shutting down HyperSwarm...');
|
||||||
this.destroy().then(() => {
|
await this.destroy()
|
||||||
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() {
|
||||||
@ -89,8 +87,8 @@ class Client extends EventEmitter {
|
|||||||
for (const peer of peers) peer.write(data);
|
for (const peer of peers) peer.write(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
destroy() {
|
async destroy() {
|
||||||
this.swarm.destroy();
|
await this.swarm.destroy();
|
||||||
console.log(`Bot ${this.botName} disconnected.`);
|
console.log(`Bot ${this.botName} disconnected.`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user