take into account config in ipfs service check

This commit is contained in:
Iuri Matias 2017-12-07 10:26:17 -05:00
parent c68c1b2d74
commit 58cf9ca78d
2 changed files with 15 additions and 2 deletions

1
.gitignore vendored
View File

@ -1,5 +1,6 @@
node_modules
TODO
NOTES
.node-xmlhttprequest-sync-*
demo/dist/
demo/.embark/development/

View File

@ -176,13 +176,25 @@ class Engine {
ipfsService(_options) {
let self = this;
let storageConfig = this.config.storageConfig;
if (!storageConfig.enabled) {
return;
}
if (storageConfig.provider !== 'ipfs' && storageConfig.available_providers.indexOf("ipfs") < 0) {
return;
}
let host = _options.host || storageConfig.host;
let port = _options.port || storageConfig.port;
self.servicesMonitor.addCheck('IPFS', function (cb) {
utils.checkIsAvailable('http://localhost:5001', function (available) {
utils.checkIsAvailable('http://' + host + ':' + port, function (available) {
if (available) {
//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...");
utils.httpGet('http://localhost:5001/api/v0/version', function (res) {
utils.httpGet('http://' + host + ':' + port + '/api/v0/version', function (res) {
let body = '';
res.on('data', function (d) {
body += d;