Services: add properties files and scripts to create separate configuration per environment

This commit is contained in:
argirok 2022-10-03 12:22:13 +03:00
parent b5fc3c8606
commit e4586e58f2
13 changed files with 70 additions and 20 deletions

25
services/cache/mecache/README.md vendored Normal file
View File

@ -0,0 +1,25 @@
# README #
### What is this repository for? ###
Cache service
* Version 1.0.0
### How to run locally? ###
* "npm start" to start the service
* Check properties to set the port
### How to run in a server? ###
* run "npm run prepare-{CONFIGURATION_NAME}"
* cp dist folder in the server
* create a folder for the service files
* "npm i" to install dependencies.
* if you just update the project run "pm2 restart cache"
* if you start a new service run: pm2 start --name cache ./cache.js --log-date-format="YYYY-MM-DD HH:mm Z"

View File

@ -0,0 +1 @@
port = 4000

View File

@ -6,6 +6,8 @@ let mcache = require('memory-cache');
const request = require('superagent');
const prom = require('prom-client');
const URL = require('url');
var PropertiesReader = require('properties-reader');
var properties = PropertiesReader('./properties.file');
const expireShort = 2 * 60 * 1000; //2mins
const expireLong = 24 * 60 * 60 * 1000; //24 hours
const cacheMaxSize = 500;
@ -136,8 +138,8 @@ app.use((req, res) => {
res.status(404).send(getResponse(404, "Not Found")); //not found
});
app.listen((process.env.PORT) ? process.env.PORT : 3000, function () {
console.log(`Example app listening on port ${(process.env.PORT) ? process.env.PORT : 3000}!`)
const server = app.listen(properties.get('port'), function () {
console.log(`Example app listening on port`, server.address().port)
//run the timer
resetAtMidnight();
});

View File

@ -4,14 +4,18 @@
"description": "Caching in memory",
"main": "cache.js",
"scripts": {
"start": "PORT=3200 node cache.js"
"start": "node cache.js",
"prepare-dist": "rm -rf dist; mkdir dist; cp package.json ./dist; cp cache.js ./dist; cp properties.file ./dist;",
"prepare-beta":" npm run prepare-dist; cp beta-properties.file ./dist/properties.file",
"prepare-prod":" npm run prepare-dist; cp production-properties.file ./dist/properties.file"
},
"dependencies": {
"cors": "^2.8.5",
"express": "^4.15.2",
"memory-cache": "^0.2.0",
"superagent": "^5.0.5",
"prom-client": "^11.3.0"
"prom-client": "^11.3.0",
"properties-reader": "0.0.16"
},
"engines": {
"node": "16.3.0"

View File

@ -0,0 +1 @@
port = 4000

View File

@ -0,0 +1 @@
port = 3200

View File

@ -0,0 +1,24 @@
# README #
### What is this repository for? ###
Utils service
* Version 1.0.0
### How to run locally? ###
* "npm start" to start the service
### How to run in a server? ###
* run "npm run prepare-{CONFIGURATION_NAME}"
* cp dist folder in the server
* create a folder for the service files
* "npm i" to install dependencies.
* if you just update the project run "pm2 restart upload"
* if you start a new service run: pm2 start --name upload ./uploadService.js --log-date-format="YYYY-MM-DD HH:mm Z"

View File

@ -5,3 +5,4 @@ localPath = false
max.size = 200
# file size in KB
big-max.size = 1000
port = 8000

View File

@ -4,7 +4,10 @@
"description": "",
"main": "index.js",
"scripts": {
"start": "node uploadService.js"
"start": "node uploadService.js",
"prepare-dist": "rm -rf dist; mkdir dist; cp package.json ./dist; cp uploadService.js ./dist; cp properties.file ./dist;",
"prepare-beta":" npm run prepare-dist; cp beta-properties.file ./dist/properties.file",
"prepare-prod":" npm run prepare-dist; cp production-properties.file ./dist/properties.file"
},
"keywords": [],
"author": "",

View File

@ -1,14 +0,0 @@
#uncomment properties file based on deployment environment
#mv beta-properties.file properties.file
#mv production-properties.file properties.file
#rm -rf node_modules/ run.sh uploads/ .idea/ beta-properties.file production-properties.file
#rm prepareDeploy.sh
#Copy files to beta.explore.openaire.eu or explore.openaire.eu /home/argiro.kokogiannaki/portals/utils-service.YYYY-MM-DD
# run npm i
#change to user nodejs " sudo su nodejs -s /bin/bash"
#copy files to deploy folder " cp -r /home/argiro.kokogiannaki/portals/utils-service.YYY-MM-DD/* /srv/www/upload/"
# restart uplication "pm2 restart upload"

View File

@ -5,3 +5,4 @@ localPath = false
max.size = 200
# file size in KB
big-max.size = 1000
port = 8000

View File

@ -5,3 +5,4 @@ localPath = true
max.size = 200
# file size in KB
big-max.size = 1000
port = 8000

View File

@ -97,7 +97,7 @@ app.delete(['/delete/:filename', '/delete/stakeholder/:filename', '/delete/:type
});
});
const server = app.listen(8000, function () {
const server = app.listen(properties.get('port'), function () {
console.log("Listening on port %s...", server.address().port);
});