1
+ /* eslint-disable no-new */
1
2
const Cryptr = require ( 'cryptr' ) ;
2
3
const { promises } = require ( 'fs' ) ;
3
4
const { readFile } = require ( 'fs' ) ;
4
- const Cron = require ( 'croner' ) ;
5
+ const { Cron } = require ( 'croner' ) ;
5
6
require ( 'dotenv' ) . config ( { path : './.env.local' } ) ;
6
7
7
8
const getAppSettings = async ( ) => {
@@ -71,7 +72,7 @@ const runAppCronJobs = () => {
71
72
const scrape_interval = settings . scrape_interval || 'daily' ;
72
73
if ( scrape_interval !== 'never' ) {
73
74
const scrapeCronTime = generateCronTime ( scrape_interval ) ;
74
- Cron ( scrapeCronTime , ( ) => {
75
+ new Cron ( scrapeCronTime , ( ) => {
75
76
// console.log('### Running Keyword Position Cron Job!');
76
77
const fetchOpts = { method : 'POST' , headers : { Authorization : `Bearer ${ process . env . APIKEY } ` } } ;
77
78
fetch ( `${ process . env . NEXT_PUBLIC_APP_URL } /api/cron` , fetchOpts )
@@ -89,7 +90,7 @@ const runAppCronJobs = () => {
89
90
if ( notif_interval ) {
90
91
const cronTime = generateCronTime ( notif_interval === 'daily' ? 'daily_morning' : notif_interval ) ;
91
92
if ( cronTime ) {
92
- Cron ( cronTime , ( ) => {
93
+ new Cron ( cronTime , ( ) => {
93
94
// console.log('### Sending Notification Email...');
94
95
const fetchOpts = { method : 'POST' , headers : { Authorization : `Bearer ${ process . env . APIKEY } ` } } ;
95
96
fetch ( `${ process . env . NEXT_PUBLIC_APP_URL } /api/notify` , fetchOpts )
@@ -106,7 +107,7 @@ const runAppCronJobs = () => {
106
107
107
108
// Run Failed scraping CRON (Every Hour)
108
109
const failedCronTime = generateCronTime ( 'hourly' ) ;
109
- Cron ( failedCronTime , ( ) => {
110
+ new Cron ( failedCronTime , ( ) => {
110
111
// console.log('### Retrying Failed Scrapes...');
111
112
112
113
readFile ( `${ process . cwd ( ) } /data/failed_queue.json` , { encoding : 'utf-8' } , ( err , data ) => {
@@ -135,7 +136,7 @@ const runAppCronJobs = () => {
135
136
// Run Google Search Console Scraper Daily
136
137
if ( process . env . SEARCH_CONSOLE_PRIVATE_KEY && process . env . SEARCH_CONSOLE_CLIENT_EMAIL ) {
137
138
const searchConsoleCRONTime = generateCronTime ( 'daily' ) ;
138
- Cron ( searchConsoleCRONTime , ( ) => {
139
+ new Cron ( searchConsoleCRONTime , ( ) => {
139
140
const fetchOpts = { method : 'POST' , headers : { Authorization : `Bearer ${ process . env . APIKEY } ` } } ;
140
141
fetch ( `${ process . env . NEXT_PUBLIC_APP_URL } /api/searchconsole` , fetchOpts )
141
142
. then ( ( res ) => res . json ( ) )
0 commit comments