feat: handle termination

This commit is contained in:
2019-01-30 09:51:31 -07:00
parent ed6186f63b
commit 3c020d25ed

View File

@@ -42,6 +42,14 @@ async function run() {
// initial kickoff
await fetchAndIndex().catch(handleError);
// listen for termination
const terminate = () => {
console.log('Terminating...');
process.exit(0);
};
process.on('SIGINT', terminate);
process.on('SIGTERM', terminate);
// scheduled running
if (interval === 0) return;
logger.debug(`Starting interval (${interval}s)...`);