1 Commits

Author SHA1 Message Date
7bbe31f4ea feat: handle termination 2019-01-30 09:59:15 -07:00

View File

@@ -42,6 +42,15 @@ 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'));
process.on('SIGKILL', terminate('SIGKILL'));
// scheduled running
if (interval === 0) return;
logger.debug(`Starting interval (${interval}s)...`);