mirror of https://github.com/embarklabs/embark.git
refactor storage module
This commit is contained in:
parent
eadbeb0498
commit
60c687aa41
|
@ -155,13 +155,9 @@ class Storage {
|
|||
this._embark.addProviderInit('storage', code, shouldInit);
|
||||
}
|
||||
|
||||
startStorageProcesses(){
|
||||
let platform = this._storageConfig.upload.provider;
|
||||
let self = this;
|
||||
|
||||
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)})};
|
||||
checkStorageService(platform, url, callback) {
|
||||
const self = this;
|
||||
const errorObj = {message: __('Cannot upload: {{platform}} node is not running on {{url}}.', {platform: platform, url: url})};
|
||||
|
||||
// start the upload storage node
|
||||
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){
|
||||
// start any dappConnection storage nodes
|
||||
self._validDappProviders.forEach(dappConn => {
|
||||
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._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();
|
||||
});
|
||||
});
|
||||
});
|
||||
self.checkStorageService(dappConn.provider, utils.buildUrlFromConfig(dappConn), callback);
|
||||
});
|
||||
}
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue