Merge pull request #396 from tuxcanfly/sigint-close
bin: handle close when interrupted
This commit is contained in:
commit
8630a8ee51
4
bin/node
4
bin/node
@ -44,6 +44,10 @@ process.on('unhandledRejection', (err, promise) => {
|
|||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on('SIGINT', async () => {
|
||||||
|
await node.close();
|
||||||
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await node.ensure();
|
await node.ensure();
|
||||||
await node.open();
|
await node.open();
|
||||||
|
|||||||
@ -33,6 +33,10 @@ process.on('unhandledRejection', (err, promise) => {
|
|||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on('SIGINT', async () => {
|
||||||
|
await node.close();
|
||||||
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await node.ensure();
|
await node.ensure();
|
||||||
await node.open();
|
await node.open();
|
||||||
|
|||||||
@ -38,6 +38,10 @@ process.on('unhandledRejection', (err, promise) => {
|
|||||||
throw err;
|
throw err;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
process.on('SIGINT', async () => {
|
||||||
|
await node.close();
|
||||||
|
});
|
||||||
|
|
||||||
(async () => {
|
(async () => {
|
||||||
await node.ensure();
|
await node.ensure();
|
||||||
await node.open();
|
await node.open();
|
||||||
|
|||||||
@ -251,9 +251,8 @@ class FullNode extends Node {
|
|||||||
await this.miner.close();
|
await this.miner.close();
|
||||||
await this.mempool.close();
|
await this.mempool.close();
|
||||||
await this.chain.close();
|
await this.chain.close();
|
||||||
await this.handleClose();
|
|
||||||
|
|
||||||
this.logger.info('Node is closed.');
|
await this.handleClose();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@ -210,6 +210,8 @@ class Node extends EventEmitter {
|
|||||||
this.bound.length = 0;
|
this.bound.length = 0;
|
||||||
this.startTime = -1;
|
this.startTime = -1;
|
||||||
|
|
||||||
|
this.logger.info('Node is closed.');
|
||||||
|
|
||||||
await this.workers.close();
|
await this.workers.close();
|
||||||
await this.logger.close();
|
await this.logger.close();
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user