detect when ethereum node comes back online and redeploy
This commit is contained in:
parent
8d8ff671f7
commit
54420b327e
|
@ -1,5 +1,8 @@
|
|||
var async = require('../utils/async_extend.js');
|
||||
|
||||
// TODO: need to separate colors from states
|
||||
// i.e use status: /on|off|warn/ not /red|green/
|
||||
// it's up to the logger or console to determine the color
|
||||
var ServicesMonitor = function(options) {
|
||||
this.events = options.events;
|
||||
this.logger = options.logger;
|
||||
|
@ -16,7 +19,15 @@ ServicesMonitor.prototype.initCheck = function(checkName) {
|
|||
if (!check) { return false; }
|
||||
|
||||
self.events.on('check:' + checkName, function(obj) {
|
||||
// TODO: see todo above
|
||||
if (check && check.status === 'red' && obj.status === 'green') {
|
||||
self.events.emit('check:backOnline:' + checkName);
|
||||
}
|
||||
if (check && check.status === 'green' && obj.status === 'red') {
|
||||
self.events.emit('check:wentOffline:' + checkName);
|
||||
}
|
||||
self.checkState[checkName] = obj.name[obj.status];
|
||||
check.status = obj.status;
|
||||
self.events.emit("servicesState", self.checkState);
|
||||
});
|
||||
|
||||
|
|
10
lib/index.js
10
lib/index.js
|
@ -103,12 +103,21 @@ var Embark = {
|
|||
engine.logger.info("loaded plugins: " + pluginList.join(", "));
|
||||
}
|
||||
|
||||
engine.startMonitor();
|
||||
engine.startService("web3");
|
||||
engine.startService("pipeline");
|
||||
engine.startService("abi");
|
||||
engine.startService("deployment");
|
||||
engine.startService("ipfs");
|
||||
|
||||
engine.events.on('check:backOnline:Ethereum', function() {
|
||||
engine.logger.info('Ethereum node detected..');
|
||||
engine.config.reloadConfig();
|
||||
engine.deployManager.deployContracts(function() {
|
||||
engine.logger.info('Deployment Done');
|
||||
});
|
||||
});
|
||||
|
||||
engine.deployManager.deployContracts(function() {
|
||||
engine.startService("fileWatcher");
|
||||
if (options.runWebserver) {
|
||||
|
@ -117,7 +126,6 @@ var Embark = {
|
|||
port: options.serverPort
|
||||
});
|
||||
}
|
||||
engine.startMonitor();
|
||||
callback();
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue