Added node schedule to run crawler and notification service
This commit is contained in:
22
index.js
22
index.js
@@ -10,6 +10,9 @@ const { getQuerySubmit, postQuerySubmit } = require('./app/controllers/querySubm
|
||||
const { getGoAgain } = require('./app/controllers/goAgain');
|
||||
const { getNeighborhood, postNeighborhood } = require('./app/controllers/neighborhoodMap');
|
||||
const { getUnsubscribe } = require('./app/controllers/unsubscribe');
|
||||
const schedule = require('node-schedule');
|
||||
const crawlAll = require('./app/services/crawlerService')
|
||||
const processNotifications = require('./app/services/notificationService')
|
||||
|
||||
let express = require("express");
|
||||
const path = require("path");
|
||||
@@ -116,6 +119,25 @@ app.post("/api/payforalert", (req, res) => {
|
||||
});
|
||||
});
|
||||
|
||||
var runServices = async () => {
|
||||
|
||||
|
||||
}
|
||||
|
||||
runServices();
|
||||
|
||||
var rule = new schedule.RecurrenceRule();
|
||||
rule.seccond = 1;
|
||||
schedule.scheduleJob(rule, async function () {
|
||||
console.log(new Date(), 'Crawler service started');
|
||||
await crawlAll();
|
||||
console.log(new Date(), 'Crawler service finished, starting Notification service');
|
||||
await processNotifications();
|
||||
console.log(new Date(), 'Notification service finished');
|
||||
});
|
||||
|
||||
|
||||
|
||||
app.get('/', welcome);
|
||||
app.get('/vrstanekretnine/:request_id', getRealEstateTypes);
|
||||
app.get('/vrstanekretnine', getRealEstateTypes);
|
||||
|
||||
Reference in New Issue
Block a user