Added node schedule to run crawler and notification service

This commit is contained in:
Nedim Uka
2019-07-09 16:33:00 +02:00
parent 1b098f181c
commit a43723485c
6 changed files with 261 additions and 124 deletions

View File

@@ -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);