refactor storage module
This commit is contained in:
parent
eadbeb0498
commit
60c687aa41
|
@ -155,13 +155,9 @@ class Storage {
|
||||||
this._embark.addProviderInit('storage', code, shouldInit);
|
this._embark.addProviderInit('storage', code, shouldInit);
|
||||||
}
|
}
|
||||||
|
|
||||||
startStorageProcesses(){
|
checkStorageService(platform, url, callback) {
|
||||||
let platform = this._storageConfig.upload.provider;
|
const self = this;
|
||||||
let self = this;
|
const errorObj = {message: __('Cannot upload: {{platform}} node is not running on {{url}}.', {platform: platform, url: url})};
|
||||||
|
|
||||||
async.waterfall([
|
|
||||||
function checkStorageService(callback){
|
|
||||||
const errorObj = {message: __('Cannot upload: {{platform}} node is not running on {{url}}.', {platform: platform, url: utils.buildUrlFromConfig(self._storageConfig.upload)})};
|
|
||||||
|
|
||||||
// start the upload storage node
|
// start the upload storage node
|
||||||
self._checkStorageEndpoint(platform, function (err) {
|
self._checkStorageEndpoint(platform, function (err) {
|
||||||
|
@ -182,32 +178,22 @@ class Storage {
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
startStorageProcesses(){
|
||||||
|
let platform = this._storageConfig.upload.provider;
|
||||||
|
let self = this;
|
||||||
|
|
||||||
|
async.waterfall([
|
||||||
|
function _checkStorageService(callback){
|
||||||
|
self.checkStorageService(platform, utils.buildUrlFromConfig(self._storageConfig.upload), callback);
|
||||||
},
|
},
|
||||||
function checkDappConnectionStorageService(callback){
|
function checkDappConnectionStorageService(callback){
|
||||||
// start any dappConnection storage nodes
|
// start any dappConnection storage nodes
|
||||||
self._validDappProviders.forEach(dappConn => {
|
self._validDappProviders.forEach(dappConn => {
|
||||||
if(!dappConn.provider || dappConn.provider === platform) return; // don't start the process we've just started above
|
if(!dappConn.provider || dappConn.provider === platform) return; // don't start the process we've just started above
|
||||||
|
|
||||||
const errorObj = {message: __('Cannot start {{platform}} node on {{url}}.', {platform: dappConn.provider, url: utils.buildUrlFromConfig(dappConn)})};
|
self.checkStorageService(dappConn.provider, utils.buildUrlFromConfig(dappConn), callback);
|
||||||
|
|
||||||
self._checkStorageEndpoint(dappConn.provider, function (err) {
|
|
||||||
if (!err) {
|
|
||||||
return callback();
|
|
||||||
}
|
|
||||||
self._startStorageNode(dappConn.provider, (err) => {
|
|
||||||
if (err) {
|
|
||||||
self._logger.error(err);
|
|
||||||
return callback(errorObj);
|
|
||||||
}
|
|
||||||
// Check endpoint again to see if really did start
|
|
||||||
self._checkStorageEndpoint(dappConn.provider, (err) => {
|
|
||||||
if (err) {
|
|
||||||
return callback(errorObj);
|
|
||||||
}
|
|
||||||
callback();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
|
Loading…
Reference in New Issue