start crawler loop when server is started
This commit is contained in:
@@ -8,8 +8,11 @@ const APP_URL =
|
||||
|
||||
const DEFAULT_TIMEZONE = "Europe/Sarajevo";
|
||||
|
||||
const CRAWLER_INTERVAL = parseInt(process.env.CRAWLER_INTERVAL) || 60;
|
||||
|
||||
module.exports = {
|
||||
APP_PORT,
|
||||
APP_URL,
|
||||
DEFAULT_TIMEZONE
|
||||
DEFAULT_TIMEZONE,
|
||||
CRAWLER_INTERVAL
|
||||
};
|
||||
|
||||
@@ -26,15 +26,14 @@ const crawlers = [
|
||||
async function crawlAll() {
|
||||
for (let crawler of crawlers) {
|
||||
try {
|
||||
const newRealEstates = await crawler.crawl();
|
||||
|
||||
console.log("Number of new real estates : ", newRealEstates.length);
|
||||
return await crawler.crawl();
|
||||
} catch (e) {
|
||||
console.log("Error crawling. Trying next crawler! ", e);
|
||||
return [];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
(async () => {
|
||||
await crawlAll();
|
||||
})();
|
||||
module.exports = {
|
||||
crawlAll
|
||||
};
|
||||
|
||||
5
app/crawler/npmCrawl.js
Normal file
5
app/crawler/npmCrawl.js
Normal file
@@ -0,0 +1,5 @@
|
||||
const { crawlAll } = require("./crawl");
|
||||
|
||||
(async () => {
|
||||
await crawlAll();
|
||||
})();
|
||||
Reference in New Issue
Block a user