1 Commits

Author SHA1 Message Date
e644475fbc feat: handle termination 2019-01-30 09:52:30 -07:00

View File

@@ -43,12 +43,12 @@ async function run() {
await fetchAndIndex().catch(handleError); await fetchAndIndex().catch(handleError);
// listen for termination // listen for termination
const terminate = () => { const terminate = type => () => {
console.log('Terminating...'); console.log(`Terminating [${type}]`);
process.exit(0); process.exit(0);
}; };
process.on('SIGINT', terminate); process.on('SIGINT', terminate('SIGINT'));
process.on('SIGTERM', terminate); process.on('SIGTERM', terminate('SIGTERM'));
// scheduled running // scheduled running
if (interval === 0) return; if (interval === 0) return;