Merge pull request #533 from embark-framework/bug_fix/ipfs-service-check-error

Storage provider initialisation fixes and improvements.
This commit is contained in:
Iuri Matias 2018-06-15 18:09:30 -04:00 committed by GitHub
commit 7706e276bf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 35 additions and 13 deletions

View File

@ -57,7 +57,7 @@ class IPFS {
} }
function versionCb(err, body) { function versionCb(err, body) {
if (err) { if (err) {
self.logger.trace("Check IPFS version error: " + err); self.logger.trace("IPFS unavailable");
return cb({name: "IPFS ", status: 'off'}); return cb({name: "IPFS ", status: 'off'});
} }
if (body.Version) { if (body.Version) {

View File

@ -156,24 +156,22 @@ class Storage {
checkStorageService(platform, url, callback) { checkStorageService(platform, url, callback) {
const self = this; const self = this;
const errorObj = {message: __('Cannot upload: {{platform}} node is not running on {{url}}.', {platform: platform, url: url})};
// start the upload storage node // start the upload storage node
self._checkStorageEndpoint(platform, function (err) { self._checkStorageEndpoint(platform, function (err) {
if (!err) { if (!err) {
return callback(); return callback(null);
} }
self._startStorageNode(platform, (err) => { self._startStorageNode(platform, (err) => {
if (err) { if (err) {
self._logger.error(err); return callback(err);
return callback(errorObj);
} }
// Check endpoint again to see if really did start // Check endpoint again to see if really did start
self._checkStorageEndpoint(platform, (err) => { self._checkStorageEndpoint(platform, (err) => {
if (err) { if (err) {
return callback(errorObj); return callback(err);
} }
callback(); callback(null);
}); });
}); });
}); });
@ -182,20 +180,44 @@ class Storage {
startStorageProcesses(){ startStorageProcesses(){
let platform = this._storageConfig.upload.provider; let platform = this._storageConfig.upload.provider;
let self = this; let self = this;
let withErrors = false;
async.waterfall([ async.waterfall([
function _checkStorageService(callback){ function _checkStorageService(callback){
self.checkStorageService(platform, utils.buildUrlFromConfig(self._storageConfig.upload), callback); self.checkStorageService(platform, utils.buildUrlFromConfig(self._storageConfig.upload), (err) => {
// log error and continue
if(err){
self._logger.error(err);
withErrors = true;
}
callback(null);
});
}, },
function checkDappConnectionStorageService(callback){ function checkDappConnectionStorageService(callback){
// start any dappConnection storage nodes // start any dappConnection storage nodes
self._validDappProviders.forEach(dappConn => { async.each(self._validDappProviders, function(dappConn, cb) {
if(!dappConn.provider || dappConn.provider === platform) return; // don't start the process we've just started above if(!dappConn.provider || dappConn.provider === platform) {
return cb(null);
} // don't start the process we've just started above
self.checkStorageService(dappConn.provider, utils.buildUrlFromConfig(dappConn), callback); self.checkStorageService(dappConn.provider, utils.buildUrlFromConfig(dappConn), (err) => {
}); // log error and continue
if(err){
self._logger.error(err);
withErrors = true;
}
cb(null);
});
}, callback);
} }
]); ], function (){
let strComplete = __('Finished starting all storage providers');
if(withErrors){
strComplete += ', ' + __('with errors.');
return self._logger.warn(strComplete);
}
self._logger.info(strComplete + '.');
});
} }
} }