diff --git a/bin/index.js b/bin/index.js index ef3b6ba..41e3a0a 100644 --- a/bin/index.js +++ b/bin/index.js @@ -42,6 +42,14 @@ async function run() { // initial kickoff await fetchAndIndex().catch(handleError); + // listen for termination + const terminate = type => () => { + console.log(`Terminating [${type}]`); + process.exit(0); + }; + process.on('SIGINT', terminate('SIGINT')); + process.on('SIGTERM', terminate('SIGTERM')); + // scheduled running if (interval === 0) return; logger.debug(`Starting interval (${interval}s)...`);