24 lines
495 B
JavaScript
24 lines
495 B
JavaScript
|
#!/usr/bin/env node
|
||
|
const CronJob = require('cron').CronJob;
|
||
|
|
||
|
// load env variables from file
|
||
|
require('dotenv').config();
|
||
|
|
||
|
const Bulgaria = require('./ncas/bg');
|
||
|
|
||
|
async function run() {
|
||
|
const bgScraper = new Bulgaria();
|
||
|
|
||
|
if (typeof(process.env.BG_CRON) === 'string' )
|
||
|
new CronJob(process.env.BG_CRON, async function() {
|
||
|
await bgScraper.run();
|
||
|
}, null, true);
|
||
|
|
||
|
if (process.env.SCRAPE_START === bgScraper.id)
|
||
|
await bgScraper.run();
|
||
|
|
||
|
console.log('BG launched');
|
||
|
}
|
||
|
|
||
|
run();
|