mirror of https://github.com/embarklabs/embark.git
check swarm connection before attempting to connect
This commit is contained in:
parent
513659a53e
commit
7a612ea5df
|
@ -29,6 +29,14 @@ class Swarm {
|
||||||
this.setServiceCheck();
|
this.setServiceCheck();
|
||||||
this.addProviderToEmbarkJS();
|
this.addProviderToEmbarkJS();
|
||||||
this.startProcess(() => {});
|
this.startProcess(() => {});
|
||||||
|
|
||||||
|
this._checkService((err) => {
|
||||||
|
if (!err) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
self.logger.info("Swarm node not found, attempting to start own node");
|
||||||
|
self.startProcess(() => {});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
commandlineDeploy() {
|
commandlineDeploy() {
|
||||||
|
@ -64,16 +72,23 @@ class Swarm {
|
||||||
|
|
||||||
self.events.request("services:register", 'Swarm', function(cb){
|
self.events.request("services:register", 'Swarm', function(cb){
|
||||||
self.logger.trace(`Checking Swarm availability on ${self.bzz.currentProvider}...`);
|
self.logger.trace(`Checking Swarm availability on ${self.bzz.currentProvider}...`);
|
||||||
self.bzz.isAvailable().then(result => {
|
self._checkService((err, result) => {
|
||||||
self.logger.trace("Swarm " + (result ? '':'un') + "available");
|
if (err) {
|
||||||
|
self.logger.trace("Check Swarm availability error: " + err);
|
||||||
|
return cb({name: "Swarm ", status: 'off'});
|
||||||
|
}
|
||||||
|
self.logger.trace("Swarm " + (result ? '':'on') + "available");
|
||||||
return cb({name: "Swarm ", status: result ? 'on':'off'});
|
return cb({name: "Swarm ", status: result ? 'on':'off'});
|
||||||
}).catch(err => {
|
|
||||||
self.logger.trace("Check Swarm availability error: " + err);
|
|
||||||
return cb({name: "Swarm ", status: 'off'});
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
_checkService(cb) {
|
||||||
|
this.bzz.isAvailable().then(result => {
|
||||||
|
cb(null, result);
|
||||||
|
}).catch(cb);
|
||||||
|
}
|
||||||
|
|
||||||
addProviderToEmbarkJS() {
|
addProviderToEmbarkJS() {
|
||||||
// TODO: make this a shouldAdd condition
|
// TODO: make this a shouldAdd condition
|
||||||
if (this.storageConfig === {}) {
|
if (this.storageConfig === {}) {
|
||||||
|
|
Loading…
Reference in New Issue