Fixed issue with logic to detect if IPFS node is online. If the IPFS node is not running and there's another service in the computer running on port 5001 it could cause an exception.

This commit is contained in:
Andy Nogueira 2017-03-08 09:46:15 -05:00
parent 71121cdc4b
commit 82042c01c6
1 changed files with 13 additions and 8 deletions

View File

@ -70,6 +70,7 @@ ServicesMonitor.prototype.check = function() {
body += d; body += d;
}); });
res.on('end', function() { res.on('end', function() {
try{
var parsed = JSON.parse(body); var parsed = JSON.parse(body);
if(parsed.Version){ if(parsed.Version){
result.push(("IPFS " + parsed.Version).green); result.push(("IPFS " + parsed.Version).green);
@ -77,11 +78,15 @@ ServicesMonitor.prototype.check = function() {
else{ else{
result.push("IPFS".green); result.push("IPFS".green);
} }
}
catch (e){
result.push("IPFS".red);
}
callback(null, result); callback(null, result);
}); });
res.on('error', function(err) { res.on('error', function(err) {
self.logger.trace("Check IPFS version error: " + err); self.logger.trace("Check IPFS version error: " + err);
result.push("IPFS".green); result.push("IPFS".red);
callback(null, result); callback(null, result);
}); });
}); });
@ -93,8 +98,8 @@ ServicesMonitor.prototype.check = function() {
}); });
}, },
function checkDevServer(result, callback) { function checkDevServer(result, callback) {
var host = self.serverHost || self.config.webServerConfig.host; var host = self.config.webServerConfig.host || self.serverHost;
var port = self.serverPort || self.config.webServerConfig.port; var port = self.config.webServerConfig.port || self.serverPort;
self.logger.trace('checkDevServer'); self.logger.trace('checkDevServer');
var devServer = 'Webserver (http://' + host + ':' + port + ')'; var devServer = 'Webserver (http://' + host + ':' + port + ')';
devServer = (self.runWebserver) ? devServer.green : devServer.red; devServer = (self.runWebserver) ? devServer.green : devServer.red;