diff --git a/backend/src/api/disk-cache.ts b/backend/src/api/disk-cache.ts index 432e22922..30683f277 100644 --- a/backend/src/api/disk-cache.ts +++ b/backend/src/api/disk-cache.ts @@ -7,13 +7,22 @@ class DiskCache { constructor() { process.on('SIGINT', () => { - this.saveData(JSON.stringify({ - mempool: memPool.getMempool(), - blocks: blocks.getBlocks(), - })); - console.log('Mempool and blocks data saved to disk cache'); + this.saveCacheToDisk(); process.exit(2); }); + + process.on('SIGTERM', () => { + this.saveCacheToDisk(); + process.exit(2); + }); + } + + saveCacheToDisk() { + this.saveData(JSON.stringify({ + mempool: memPool.getMempool(), + blocks: blocks.getBlocks(), + })); + console.log('Mempool and blocks data saved to disk cache'); } loadMempoolCache() {