add ENV variable to control crawler execution

This commit is contained in:
Bilal Catic
2019-09-26 23:55:34 +02:00
parent 2e92f961ff
commit c5a720484a
4 changed files with 19 additions and 15 deletions

View File

@@ -9,10 +9,12 @@ const APP_URL =
const DEFAULT_TIMEZONE = "Europe/Sarajevo"; const DEFAULT_TIMEZONE = "Europe/Sarajevo";
const CRAWLER_INTERVAL = parseInt(process.env.CRAWLER_INTERVAL) || 60; const CRAWLER_INTERVAL = parseInt(process.env.CRAWLER_INTERVAL) || 60;
const STOP_CRAWLER = !!parseInt(process.env.STOP_CRAWLER);
module.exports = { module.exports = {
APP_PORT, APP_PORT,
APP_URL, APP_URL,
DEFAULT_TIMEZONE, DEFAULT_TIMEZONE,
CRAWLER_INTERVAL CRAWLER_INTERVAL,
STOP_CRAWLER
}; };

View File

@@ -7,7 +7,6 @@
left: 25%; left: 25%;
} }
.welcome-big-logo { .welcome-big-logo {
font-size: 200pt; font-size: 200pt;
background-image: url(./images/logo.png); background-image: url(./images/logo.png);
@@ -16,19 +15,17 @@
color: rgba(0, 0, 0, 0); color: rgba(0, 0, 0, 0);
} }
.no-ui-slider { .no-ui-slider {
width: 95% width: 95%;
} }
.centered-element { .centered-element {
margin-top: 200px; margin-top: 200px;
} }
.centered-element-small { .centered-element-small {
margin-top: 100px; margin-top: 100px;
} }
#map { #map {
height: 50%; height: 50%;
} }
@@ -38,7 +35,7 @@ body {
height: 100%; height: 100%;
margin: 0; margin: 0;
padding: 0; padding: 0;
font-family: 'Tangerine', serif; font-family: "Tangerine", serif;
} }
#floating-panel { #floating-panel {
@@ -49,7 +46,7 @@ body {
padding: 5px; padding: 5px;
border: 1px solid #999; border: 1px solid #999;
text-align: center; text-align: center;
font-family: 'Roboto', 'sans-serif'; font-family: "Roboto", "sans-serif";
line-height: 30px; line-height: 30px;
padding-left: 10px; padding-left: 10px;
} }

View File

@@ -15,6 +15,7 @@ APP_URL=http://localhost:3001
SOURCE_EMAIL=info@saburly.com SOURCE_EMAIL=info@saburly.com
CRAWLER_INTERVAL=Interval to run cralwer(s), in seconds CRAWLER_INTERVAL=Interval to run cralwer(s), in seconds
STOP_CRAWLER=Non-zero value will skip crawler execution
#=============== CRAWLER SETTINGS===============# #=============== CRAWLER SETTINGS===============#
#==OLX== #==OLX==

View File

@@ -6,7 +6,11 @@ const bodyParser = require("body-parser");
const layout = require("express-layout"); const layout = require("express-layout");
const compression = require("compression"); const compression = require("compression");
const { APP_PORT, CRAWLER_INTERVAL } = require("./app/config/appConfig"); const {
APP_PORT,
CRAWLER_INTERVAL,
STOP_CRAWLER
} = require("./app/config/appConfig");
const routes = require("./app/routes"); const routes = require("./app/routes");
const { crawlAll } = require("./app/crawler/crawl"); const { crawlAll } = require("./app/crawler/crawl");
@@ -28,7 +32,7 @@ app.listen(APP_PORT, () =>
console.log(`Example app listening on port ${APP_PORT}!`) console.log(`Example app listening on port ${APP_PORT}!`)
); );
let crawlerRunning = false; let crawlerRunning = STOP_CRAWLER;
const crawl = () => { const crawl = () => {
if (!crawlerRunning) { if (!crawlerRunning) {
crawlerRunning = true; crawlerRunning = true;