Skip to content

Commit

Permalink
Merge pull request #2 from cdmitri/master
Browse files Browse the repository at this point in the history
Minor changes
  • Loading branch information
cdmitri authored May 1, 2018
2 parents b3502fd + 593c0d4 commit 4206565
Show file tree
Hide file tree
Showing 6 changed files with 117 additions and 1 deletion.
28 changes: 28 additions & 0 deletions src/common/common.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
const LOCPICK_PORT = 50001;
const LOCPICK_DEVSHELL_PORT = 55001;

const BEACON_PORT = 50002;
const BEACON_DEVSHELL_PORT = 55002;

const ELASTIC_PORT = 50003;
const POSTGRESQL_PORT = 50005;

const STAGE1_PORT = 50006;
const STAGE1_DEVSHELL_PORT = 55006;

const ENVOY_ADMIN_PORT = 50011;
const LOCAL_SERVER_PORT = 8080;
const HOST = "127.0.0.1";

module.exports = {
ELASTIC_PORT: ELASTIC_PORT,
POSTGRESQL_PORT : POSTGRESQL_PORT,
LOCPICK_PORT: LOCPICK_PORT,
LOCPICK_DEVSHELL_PORT: LOCPICK_PORT,
BEACON_PORT: BEACON_PORT,
BEACON_DEVSHELL_PORT: BEACON_PORT,
STAGE1_PORT : STAGE1_PORT,
STAGE1_DEVSHELL_PORT : STAGE1_DEVSHELL_PORT,
LOCAL_SERVER_PORT : LOCAL_SERVER_PORT,
HOST : HOST
};
9 changes: 9 additions & 0 deletions src/common/conf.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
const LOCPICK_PORT = 50001;
const BEACON_PORT = 50002;
const ELASTIC_PORT = 50003;

module.exports = {
LOCPICK_PORT: LOCPICK_PORT,
BEACON_PORT: BEACON_PORT,
ELASTIC_PORT: ELASTIC_PORT,
};
13 changes: 13 additions & 0 deletions src/common/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "beatrak-common",
"version": "0.0.1",
"description": "utils package for beatrak",
"author": "Dmitri Chtchourov <[email protected]>",
"main": "utils.js",
"repository": "github.com/cdmitri/cio",
"license": "MIT",
"private": true,
"dependencies": {
"moment": "^2.19.2"
}
}
66 changes: 66 additions & 0 deletions src/common/utils.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
const moment = require('moment');

//
// util module for beatrak
//

// REST
// respnose is express res, req (for options), reponse is our object

LOADED = true;

const sendResponse = (res, req, response) => {
if(typeof req.query.pretty !== 'undefined') {
res.send(JSON.stringify(response, null, "\t"));
} else {
res.send(JSON.stringify(response));
}
}

const returnSuccess = (res, req, response) => {
res.status(200)
sendResponse(res, req, response);
}

const m = (message, arg1) => {
return moment().format('YYYY-MM-DDTHH:mm:ssZ') + " " + message + ((typeof arg1 === 'undefined') ? "" : JSON.stringify(arg1, null, "\t"));
}

const sleep = (ms) => new Promise(resolve => {
setTimeout(resolve,ms);
});

const expBackoff = (attempt, delay) => {
return new Promise(async (resolve, reject) => {
let ms = Math.random() * Math.pow(2, attempt) * delay;
console.log(m(`expBackoff(): starting to wait for ${ms}(ms)`));
await sleep(ms)
.then(() => {
console.log(m(`expBackoff(): done waiting`));
resolve(ms)
})
.catch( error => { reject(error) })
});
}


//module.exports.sendResponse = sendResponse;
//module.exports.returnSuccess = returnSuccess;

module.exports = {
LOADED : LOADED,
sendResponse : sendResponse,
returnSuccess : returnSuccess,
m : m,
sleep : sleep,
expBackoff : expBackoff
}









2 changes: 1 addition & 1 deletion src/grafana/var-lib-grafana-volume/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1 @@
sessions
sessionsgrafana.db
Binary file modified src/grafana/var-lib-grafana-volume/grafana.db
Binary file not shown.

0 comments on commit 4206565

Please sign in to comment.