#!/usr/bin/env node const CronJob = require('cron').CronJob; // load env variables from file require('dotenv').config(); const OutletScrape = require('./scrapers/outlet'); async function run() { const outlet = new OutletScrape(); if (typeof(process.env.outlet) === 'string' ) { console.log(`${outlet.id} cron set for ${process.env.OUTLET_CRON}`); new CronJob(process.env.OUTLET_CRON, async function() { await outlet.run(); }, null, true); } if (process.env.SCRAPE_START === outlet.id) { console.log('go'); await outlet.run(); } console.log('Outlet Launched'); } process.once('uncaughtException', function caught(err) { console.error('Uncaught', err); }); run();