30 lines
622 B
JavaScript
30 lines
622 B
JavaScript
#!/usr/bin/env node
|
|
const CronJob = require('cron').CronJob;
|
|
|
|
// load env variables from file
|
|
require('dotenv').config();
|
|
|
|
const argv = require('yargs').argv;
|
|
|
|
const Czech = require('./ncas/cz');
|
|
|
|
async function run() {
|
|
const czScraper = new Czech();
|
|
|
|
if (typeof(process.env.CZ_CRON) === 'string' )
|
|
new CronJob(process.env.CZ_CRON, async function() {
|
|
await czScraper.run();
|
|
}, null, true);
|
|
|
|
if (process.env.SCRAPE_START === czScraper.id)
|
|
await czScraper.run();
|
|
|
|
console.log('CZ Launched');
|
|
}
|
|
|
|
process.once('uncaughtException', function caught(err) {
|
|
console.error('Uncaught', err);
|
|
});
|
|
|
|
run();
|