-
Notifications
You must be signed in to change notification settings - Fork 17
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 #6 from phahulin/eventsStats-endpoint
Some optimizations
- Loading branch information
Showing
16 changed files
with
244 additions
and
115 deletions.
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
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,3 +1,6 @@ | ||
.env | ||
node_modules | ||
responses | ||
responses/* | ||
!responses/.gitkeep | ||
*.err | ||
*.out |
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
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,22 +1,30 @@ | ||
const fs = require('fs') | ||
const logger = require('./logger')('checkWorker'); | ||
const getBalances = require('./getBalances') | ||
const getShortEventStats = require('./getShortEventStats'); | ||
const validators = require('./validators'); | ||
|
||
async function checkWorker() { | ||
try { | ||
logger.debug('calling getBalances()'); | ||
const balances = await getBalances(); | ||
logger.debug('calling getShortEventStats()'); | ||
const events = await getShortEventStats(); | ||
const home = Object.assign({}, balances.home, events.home) | ||
const foreign = Object.assign({}, balances.foreign, events.foreign) | ||
const status = Object.assign({}, balances, events, {home}, {foreign}) | ||
if (!status) throw new Error('status is empty: ' + JSON.stringify(status)); | ||
fs.writeFileSync(__dirname + '/responses/getBalances.json', JSON.stringify(status,null,4)); | ||
|
||
logger.debug('calling validators()'); | ||
const vBalances = await validators(); | ||
if (!vBalances) throw new Error('vBalances is empty: ' + JSON.stringify(vBalances)); | ||
fs.writeFileSync(__dirname + '/responses/validators.json', JSON.stringify(vBalances,null,4)); | ||
logger.debug("Done"); | ||
return status; | ||
} catch(e) { | ||
console.error(e) | ||
logger.error(e); | ||
throw e; | ||
} | ||
} | ||
checkWorker(); | ||
module.exports = checkWorker; |
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,18 @@ | ||
const fs = require('fs') | ||
const logger = require('./logger')('checkWorker2'); | ||
const eventsStats = require('./eventsStats') | ||
|
||
async function checkWorker2() { | ||
try { | ||
logger.debug('calling eventsStats()'); | ||
const evStats = await eventsStats(); | ||
if (!evStats) throw new Error('evStats is empty: ' + JSON.stringify(evStats)); | ||
fs.writeFileSync(__dirname + '/responses/eventsStats.json', JSON.stringify(evStats,null,4)); | ||
logger.debug("Done"); | ||
return evStats; | ||
} catch(e) { | ||
logger.error('checkWorker2.js', e); | ||
throw e; | ||
} | ||
} | ||
checkWorker2(); |
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,2 @@ | ||
*/4 * * * * cd $HOME/bridge-monitor; node checkWorker.js >>cronWorker.out 2>>cronWorker.err | ||
*/5 * * * * cd $HOME/bridge-monitor; node checkWorker2.js >>cronWorker2.out 2>>cronWorker2.err |
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
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
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
Oops, something went wrong.