Merge pull request #222 from nogueian/develop

Implemented logic to show version of the connected IPFS node
This commit is contained in:
Iuri Matias 2017-02-23 19:42:29 -05:00 committed by GitHub
commit c35735d5b8
1 changed files with 29 additions and 5 deletions

View File

@ -1,6 +1,6 @@
var Web3 = require('web3');
var async = require('async');
var http = require('http');
var utils = require('./utils.js');
var ServicesMonitor = function(options) {
@ -60,11 +60,35 @@ ServicesMonitor.prototype.check = function() {
utils.checkIsAvailable('http://localhost:5001', function(available) {
if (available) {
result.push('IPFS'.green);
} else {
result.push('IPFS'.red);
//Ideally this method should be in an IPFS API JSONRPC wrapper
//The URL should also be flexible to accept non-default IPFS url
self.logger.trace("Checking IPFS version...");
http.get('http://localhost:5001/api/v0/version', function(res) {
var body = '';
res.on('data', function(d) {
body += d;
});
res.on('end', function() {
var parsed = JSON.parse(body);
if(parsed.Version){
result.push(("IPFS " + parsed.Version).green);
}
else{
result.push("IPFS".green);
}
callback(null, result);
});
res.on('error', function(err) {
self.logger.trace("Check IPFS version error: " + err);
result.push("IPFS".green);
callback(null, result);
});
});
}
else {
result.push('IPFS'.red);
callback(null, result);
}
callback(null, result);
});
},
function checkDevServer(result, callback) {