-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from cdmitri/master
Minor changes
- Loading branch information
Showing
6 changed files
with
117 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
sessions | ||
sessionsgrafana.db |
Binary file not shown.