Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
31 commits
Select commit Hold shift + click to select a range
e068ffc
fix cleos seq
igorls Nov 19, 2019
004ada5
Update mappings.js
igorls Nov 24, 2019
12328fa
fix cleos seq
igorls Nov 19, 2019
6535b68
Update mappings.js
igorls Nov 24, 2019
4887b28
update get_actions
igorls Nov 26, 2019
837e1da
update get_actions
igorls Nov 26, 2019
665f27e
use rem as default chain name
sergchernata Nov 26, 2019
c438231
Merge branch 'master' of https://github.com/eon-llc/Hyperion-History-API
sergchernata Nov 26, 2019
d1aa188
Update example-connections.json
igorls Nov 26, 2019
464af52
expose usage data for all 0 ordinal actions
sergchernata Nov 26, 2019
d1f2554
use rem chain as default
sergchernata Nov 26, 2019
f328199
adding 1.7 parser and API improvements
igorls Dec 7, 2019
017476e
Merge branch 'master' of https://github.com/eosrio/Hyperion-History-API
igorls Dec 7, 2019
4c6dd40
Update mappings.js
igorls Dec 7, 2019
f2ea968
Update 1.8-parser.js
igorls Dec 7, 2019
c322461
Update 1.7-parser.js
igorls Dec 7, 2019
290cf25
Update master.js
igorls Dec 7, 2019
62006c3
Update deserializer.worker.js
igorls Dec 7, 2019
cde108f
Update master.js
igorls Dec 7, 2019
4ad3e1e
Update index.js
igorls Dec 7, 2019
5aebeb6
improve startup logic
igorls Dec 7, 2019
ae6e239
small fixes
igorls Dec 7, 2019
989212a
Create daobet-eosio-undelegatebw.js
igorls Dec 7, 2019
98f621d
Update .gitignore
igorls Dec 7, 2019
b6f8b53
update actions handlers
igorls Dec 7, 2019
c1e5f5f
api updates
igorls Dec 7, 2019
e474678
add simple mode for get_actions
igorls Dec 7, 2019
a37765a
Update deserializer.worker.js
igorls Dec 8, 2019
62a4f93
Update health.js
igorls Dec 10, 2019
39d8aaf
Update health.js
igorls Dec 10, 2019
308ee7d
Merge branch 'pr/3'
sergchernata Dec 11, 2019
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,8 @@ typings/
ecosystem.config.js
package-lock.json
connections.json
api_access.log
api_error.log
explorer
api/explorer
.ecosystem.config.js.swp
102 changes: 62 additions & 40 deletions api/handlers/health.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,23 @@ const system_domain = process.env.SYSTEM_DOMAIN;
const ecosystem = require('../../ecosystem.config');

function checkFeat(name) {
return currentENV[name] === 'true';
if (currentENV) {
return currentENV[name] === 'true';
} else {
return null;
}
}

const currentENV = ecosystem.apps.find(app => app.env.CHAIN === process.env.CHAIN)['env'];
let currentENV;
if (ecosystem.apps.length > 1) {
const indexerApp = ecosystem.apps.find(app => {
return app.env.CHAIN === process.env.CHAIN && app.script === "./launcher.js";
});

if (indexerApp) {
currentENV = indexerApp['env'];
}
}

// get current github version
let last_commit_hash;
Expand Down Expand Up @@ -108,49 +121,58 @@ async function checkElastic(elastic) {
}

module.exports = function (fastify, opts, next) {
fastify.get('/health', {}, async (request, reply) => {
const t0 = Date.now();
const {redis, elastic} = fastify;
fastify.route({
url: '/health',
method: 'GET',
schema: {
tags: ['status'],
summary: "API Service Health Report"
},
handler: async (request, reply) => {
const t0 = Date.now();
const {redis, elastic} = fastify;

let cachedResponse, hash;
[cachedResponse, hash] = await getCacheByHash(redis, 'health');
if (cachedResponse) {
cachedResponse = JSON.parse(cachedResponse);
cachedResponse['query_time'] = Date.now() - t0;
cachedResponse['cached'] = true;
reply.send(cachedResponse);
return;
}
let cachedResponse, hash;
[cachedResponse, hash] = await getCacheByHash(redis, 'health');
if (cachedResponse) {
cachedResponse = JSON.parse(cachedResponse);
cachedResponse['query_time'] = Date.now() - t0;
cachedResponse['cached'] = true;
reply.send(cachedResponse);
return;
}

let response = {
version_hash: last_commit_hash,
features: {
indices: {
all_deltas: checkFeat('INDEX_ALL_DELTAS'),
transfer_memo: checkFeat('INDEX_TRANSFER_MEMO'),
},
tables: {
proposals: checkFeat('PROPOSAL_STATE'),
accounts: checkFeat('ACCOUNT_STATE'),
voters: checkFeat('VOTERS_STATE')
let response = {
version_hash: last_commit_hash,
host: process.env.SERVER_NAME,
features: {
indices: {
all_deltas: checkFeat('INDEX_ALL_DELTAS'),
transfer_memo: checkFeat('INDEX_TRANSFER_MEMO'),
},
tables: {
proposals: checkFeat('PROPOSAL_STATE'),
accounts: checkFeat('ACCOUNT_STATE'),
voters: checkFeat('VOTERS_STATE')
},
stream: {
traces: checkFeat('STREAM_TRACES'),
deltas: checkFeat('STREAM_DELTAS')
}
},
stream: {
traces: checkFeat('STREAM_TRACES'),
deltas: checkFeat('STREAM_DELTAS')
}
},
health: []
};
health: []
};

response.health.push(await checkRabbit());
response.health.push(await checkNodeos());
response.health.push(await checkRedis(redis));
response.health.push(await checkElastic(elastic));
response['query_time'] = Date.now() - t0;
response.health.push(await checkRabbit());
response.health.push(await checkNodeos());
response.health.push(await checkRedis(redis));
response.health.push(await checkElastic(elastic));
response['query_time'] = Date.now() - t0;

// prevent abuse of the health endpoint
redis.set(hash, JSON.stringify(response), 'EX', 10);
reply.send(response);
// prevent abuse of the health endpoint
redis.set(hash, JSON.stringify(response), 'EX', 10);
reply.send(response);
}
});
next();
};
Loading