From cbc06852311e30d981da154a99dcf188ebcfdbad Mon Sep 17 00:00:00 2001 From: Dmitri Chtchourov Date: Tue, 1 May 2018 05:29:07 +0000 Subject: [PATCH 1/3] Re-imported src/common, modded grafana db --- src/common/common.js | 28 +++++++++++++++++ src/common/conf.js | 9 ++++++ src/common/package.json | 13 ++++++++ src/common/utils.js | 66 +++++++++++++++++++++++++++++++++++++++++ 4 files changed, 116 insertions(+) create mode 100644 src/common/common.js create mode 100644 src/common/conf.js create mode 100644 src/common/package.json create mode 100644 src/common/utils.js diff --git a/src/common/common.js b/src/common/common.js new file mode 100644 index 0000000..51435c3 --- /dev/null +++ b/src/common/common.js @@ -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 +}; diff --git a/src/common/conf.js b/src/common/conf.js new file mode 100644 index 0000000..36be7f5 --- /dev/null +++ b/src/common/conf.js @@ -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, +}; diff --git a/src/common/package.json b/src/common/package.json new file mode 100644 index 0000000..5acac56 --- /dev/null +++ b/src/common/package.json @@ -0,0 +1,13 @@ +{ + "name": "beatrak-common", + "version": "0.0.1", + "description": "utils package for beatrak", + "author": "Dmitri Chtchourov ", + "main": "utils.js", + "repository": "github.com/cdmitri/cio", + "license": "MIT", + "private": true, + "dependencies": { + "moment": "^2.19.2" + } +} diff --git a/src/common/utils.js b/src/common/utils.js new file mode 100644 index 0000000..7c233cd --- /dev/null +++ b/src/common/utils.js @@ -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 +} + + + + + + + + + From d7b1821840ae40b61bca05b3ae9e2302537c753e Mon Sep 17 00:00:00 2001 From: Dmitri Chtchourov Date: Tue, 1 May 2018 05:36:20 +0000 Subject: [PATCH 2/3] Minor adds --- src/grafana/var-lib-grafana-volume/.gitignore | 2 +- src/grafana/var-lib-grafana-volume/grafana.db | Bin 506880 -> 506880 bytes 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/src/grafana/var-lib-grafana-volume/.gitignore b/src/grafana/var-lib-grafana-volume/.gitignore index 4b22163..4d483eb 100644 --- a/src/grafana/var-lib-grafana-volume/.gitignore +++ b/src/grafana/var-lib-grafana-volume/.gitignore @@ -1 +1 @@ -sessions \ No newline at end of file +sessionsgrafana.db diff --git a/src/grafana/var-lib-grafana-volume/grafana.db b/src/grafana/var-lib-grafana-volume/grafana.db index 24ab303828534bed87305dd6ef737210fa575b88..b79fbf785c71d3d35814f7c951106a2f56f4e66f 100644 GIT binary patch delta 51 zcmZqpA=mIjZh|!9--$BLjDI&K%oJxgwKBA{GBs?HXp>-UlVEC-U~ZFOX_H`WlVDpW H!M+3l+*S|K delta 51 zcmZqpA=mIjZh|!9pNTTgjDI#J%oJxgv@$ZXGO=uuXp>-UlVEC-U~ZFOX_H`WlVDpW H!M+3l+ma8= From 593c0d43eeda8d57d66edb3ebae2c43623823ffa Mon Sep 17 00:00:00 2001 From: Dmitri Chtchourov Date: Tue, 1 May 2018 05:39:59 +0000 Subject: [PATCH 3/3] Minor grafana change --- src/grafana/var-lib-grafana-volume/grafana.db | Bin 506880 -> 506880 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/src/grafana/var-lib-grafana-volume/grafana.db b/src/grafana/var-lib-grafana-volume/grafana.db index b79fbf785c71d3d35814f7c951106a2f56f4e66f..d06ccf004db147b66f239d16694a59419c46155a 100644 GIT binary patch delta 49 zcmZqpA=mIjZh|!9zlk!=jQ=(!%ob-gwy-ibX_9D@U~H3MYLj4YlVE9+U~Q9NTPDH2 F1OUE^4`u)W delta 49 zcmZqpA=mIjZh|!9--$BLjDI&K%ob-gw6rocY?5e`U~H3MYLj4YlVE9+U~Q9NTPDH2 F1OUDZ4`KiS