29 lines
636 B
JavaScript
29 lines
636 B
JavaScript
#!/usr/bin/env node
|
|
const CronJob = require('cron').CronJob;
|
|
|
|
// load env variables from file
|
|
require('dotenv').config();
|
|
|
|
const Malta = require('./ncas/mt');
|
|
|
|
async function run() {
|
|
const mtScraper = new Malta();
|
|
|
|
if (typeof(process.env.MT_CRON) === 'string' )
|
|
new CronJob(process.env.MT_CRON, async () => {
|
|
await mtScraper.run();
|
|
}, null, true);
|
|
|
|
if (process.env.SCRAPE_START === mtScraper.id)
|
|
await mtScraper.run();
|
|
|
|
console.log('scrapestart', process.env.SCRAPE_START);
|
|
console.log('MT Launched');
|
|
}
|
|
|
|
process.once('uncaughtException', function caught(err) {
|
|
console.error('Uncaught', err);
|
|
});
|
|
|
|
run();
|