[beta18 | DONE | CHANGED] beta-properties.file: Updated port property | cache.js: Added the ability to read the port either from environment variables or from the properties file.
This commit is contained in:
parent
50af4f1bd5
commit
030e25c02d
|
@ -1,4 +1,4 @@
|
||||||
port = 4000
|
port = 3100
|
||||||
utilsService = https://beta.explore.openaire.eu/utils-service
|
utilsService = https://beta.explore.openaire.eu/utils-service
|
||||||
environment = beta
|
environment = beta
|
||||||
preloadRequests =https://beta.services.openaire.eu/openaire/info/,https://beta.services.openaire.eu/openaire/contexts/,https://beta.services.openaire.eu/usagestats/allmetrics,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:provenanceActions.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:subject_classification_typologies.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:relation_relClass.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:publication_resource.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:dataCite_resource.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:languages.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:access_modes.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:datasource_typologies.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:datasourceCompatibilityLevel.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:countries.json
|
preloadRequests =https://beta.services.openaire.eu/openaire/info/,https://beta.services.openaire.eu/openaire/contexts/,https://beta.services.openaire.eu/usagestats/allmetrics,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:provenanceActions.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:subject_classification_typologies.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:relation_relClass.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:publication_resource.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:dataCite_resource.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:languages.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:access_modes.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:datasource_typologies.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:datasourceCompatibilityLevel.json,https://beta.services.openaire.eu/provision/mvc/vocabularies/dnet:countries.json
|
||||||
|
|
|
@ -21,6 +21,8 @@ const lruCache = new LRUCache({ max: cacheMaxSize });
|
||||||
const register = new prom.Registry();
|
const register = new prom.Registry();
|
||||||
prom.collectDefaultMetrics({register: register});
|
prom.collectDefaultMetrics({register: register});
|
||||||
|
|
||||||
|
const port = process.env['PORT'] || properties.get('port');
|
||||||
|
|
||||||
const responses = new prom.Counter({
|
const responses = new prom.Counter({
|
||||||
name: 'cache_http_responses_total',
|
name: 'cache_http_responses_total',
|
||||||
help: 'A counter for cache response codes for every API request.',
|
help: 'A counter for cache response codes for every API request.',
|
||||||
|
@ -160,7 +162,7 @@ app.use((req, res) => {
|
||||||
res.status(404).send(getResponse(404, "Not Found")); //not found
|
res.status(404).send(getResponse(404, "Not Found")); //not found
|
||||||
});
|
});
|
||||||
|
|
||||||
const server = app.listen(properties.get('port'), function () {
|
const server = app.listen(port, function () {
|
||||||
console.log(`Example app listening on port`, server.address().port)
|
console.log(`Example app listening on port`, server.address().port)
|
||||||
//run the timer
|
//run the timer
|
||||||
resetAtMidnight();
|
resetAtMidnight();
|
||||||
|
@ -184,14 +186,14 @@ function clearCache() {
|
||||||
async function initCache() {
|
async function initCache() {
|
||||||
try {
|
try {
|
||||||
const requests = await axios.get(properties.get('utilsService') + '/grouped-requests');
|
const requests = await axios.get(properties.get('utilsService') + '/grouped-requests');
|
||||||
const additionalDataPromises = requests.data.map((url) => axios.get('http://localhost:'+properties.get('port') + '/get?url=' + properties.get('utilsService') + url));
|
const additionalDataPromises = requests.data.map((url) => axios.get('http://localhost:'+port + '/get?url=' + properties.get('utilsService') + url));
|
||||||
const additionalDataResponses = await Promise.all(additionalDataPromises);
|
const additionalDataResponses = await Promise.all(additionalDataPromises);
|
||||||
console.log("Cache initialized group queries!")
|
console.log("Cache initialized group queries!")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
console.error('Error fetching data: Cache initialize failed', error);
|
console.error('Error fetching data: Cache initialize failed', error);
|
||||||
}
|
}
|
||||||
try{
|
try{
|
||||||
const additionalDataPromisesPreloadRequests = preloadRequests.map((url) => axios.get('http://localhost:'+properties.get('port') + '/get?url=' + url));
|
const additionalDataPromisesPreloadRequests = preloadRequests.map((url) => axios.get('http://localhost:'+port + '/get?url=' + url));
|
||||||
const additionalDataResponsesPreloadRequests = await Promise.all(additionalDataPromisesPreloadRequests);
|
const additionalDataResponsesPreloadRequests = await Promise.all(additionalDataPromisesPreloadRequests);
|
||||||
console.log("Cache initialized preload requests!")
|
console.log("Cache initialized preload requests!")
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|
Loading…
Reference in New Issue