Merge pull request #396 from tuxcanfly/sigint-close

bin: handle close when interrupted
This commit is contained in:
Javed Khan 2018-09-17 23:57:48 +05:30 committed by GitHub
commit 8630a8ee51
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 15 additions and 2 deletions

View File

@ -44,6 +44,10 @@ process.on('unhandledRejection', (err, promise) => {
throw err;
});
process.on('SIGINT', async () => {
await node.close();
});
(async () => {
await node.ensure();
await node.open();

View File

@ -33,6 +33,10 @@ process.on('unhandledRejection', (err, promise) => {
throw err;
});
process.on('SIGINT', async () => {
await node.close();
});
(async () => {
await node.ensure();
await node.open();

View File

@ -38,6 +38,10 @@ process.on('unhandledRejection', (err, promise) => {
throw err;
});
process.on('SIGINT', async () => {
await node.close();
});
(async () => {
await node.ensure();
await node.open();

View File

@ -251,9 +251,8 @@ class FullNode extends Node {
await this.miner.close();
await this.mempool.close();
await this.chain.close();
await this.handleClose();
this.logger.info('Node is closed.');
await this.handleClose();
}
/**

View File

@ -210,6 +210,8 @@ class Node extends EventEmitter {
this.bound.length = 0;
this.startTime = -1;
this.logger.info('Node is closed.');
await this.workers.close();
await this.logger.close();
}