bin: handle close when interrupted

This commit is contained in:
Javed Khan 2018-01-05 11:54:48 +05:30
parent fcba00ef5b
commit b18a8a3f13
No known key found for this signature in database
GPG Key ID: 7E31745B904584E6
4 changed files with 14 additions and 1 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,10 @@ 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();
}
/**