Added graceful shutdown #8
@ -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() {
|
||||
|
Loading…
Reference in New Issue
Block a user