fix for the timer?
This commit is contained in:
parent
63a9a11b79
commit
162224bb11
@ -8,6 +8,9 @@ const ChangeDetection = require('./scrapers/scraper');
|
||||
|
||||
async function run() {
|
||||
const cdScraper = new ChangeDetection();
|
||||
let startTime = new Date();
|
||||
let startTimeStamp = startTime.getTime();
|
||||
const delay = process.env.DELAY || 600000;
|
||||
|
||||
if (typeof(process.env.CD_CRON) === 'string' ) {
|
||||
console.log(`${cdScraper.id} cron set for ${process.env.CD_CRON}`);
|
||||
@ -26,11 +29,18 @@ async function run() {
|
||||
await cdScraper.run();
|
||||
console.log('--');
|
||||
setInterval(async () => {
|
||||
console.log('go');
|
||||
await cdScraper.run();
|
||||
console.log('ready to go again..');
|
||||
// }, parseInt(process.env.CD_EVERY, 10));
|
||||
}, process.env.CD_EVERY);
|
||||
const now = new Date();
|
||||
const nowTS = now.getTime();
|
||||
|
||||
console.log('check');
|
||||
|
||||
if (nowTS - startTimeStamp > process.env.CD_EVERY) {
|
||||
await cdScraper.run();
|
||||
console.log('ready to go again..');
|
||||
startTime = new Date();
|
||||
startTimeStamp = startTime.getTime();
|
||||
}
|
||||
}, delay);
|
||||
}
|
||||
|
||||
if (process.env.SCRAPE_START === cdScraper.id) {
|
||||
|
Loading…
Reference in New Issue
Block a user