From 58cf9ca78df76ab597108bc3727d7ca5e9111b18 Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 7 Dec 2017 10:26:17 -0500 Subject: [PATCH] take into account config in ipfs service check --- .gitignore | 1 + lib/core/engine.js | 16 ++++++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/.gitignore b/.gitignore index 3443aeb0..a25c0e34 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ node_modules TODO +NOTES .node-xmlhttprequest-sync-* demo/dist/ demo/.embark/development/ diff --git a/lib/core/engine.js b/lib/core/engine.js index 42d3a387..e1d249a2 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -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;