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.addProviderToEmbarkJS();
|
||||
this.startProcess(() => {});
|
||||
|
||||
this._checkService((err) => {
|
||||
if (!err) {
|
||||
return;
|
||||
}
|
||||
self.logger.info("Swarm node not found, attempting to start own node");
|
||||
self.startProcess(() => {});
|
||||
});
|
||||
}
|
||||
|
||||
commandlineDeploy() {
|
||||
|
@ -64,16 +72,23 @@ class Swarm {
|
|||
|
||||
self.events.request("services:register", 'Swarm', function(cb){
|
||||
self.logger.trace(`Checking Swarm availability on ${self.bzz.currentProvider}...`);
|
||||
self.bzz.isAvailable().then(result => {
|
||||
self.logger.trace("Swarm " + (result ? '':'un') + "available");
|
||||
self._checkService((err, result) => {
|
||||
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'});
|
||||
}).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() {
|
||||
// TODO: make this a shouldAdd condition
|
||||
if (this.storageConfig === {}) {
|
||||
|
|
Loading…
Reference in New Issue