mirror of
https://github.com/embarklabs/embark.git
synced 2025-02-02 08:56:11 +00:00
add service check functionality to plugin api
This commit is contained in:
parent
e8c8a85713
commit
447f967061
@ -37,6 +37,15 @@ Engine.prototype.init = function(_options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
Engine.prototype.startMonitor = function() {
|
Engine.prototype.startMonitor = function() {
|
||||||
|
var self = this;
|
||||||
|
if (this.plugins) {
|
||||||
|
var servicePlugins = this.plugins.getPluginsFor('serviceChecks');
|
||||||
|
servicePlugins.forEach(function(plugin) {
|
||||||
|
plugin.serviceChecks.forEach(function(pluginCheck) {
|
||||||
|
self.servicesMonitor.addCheck(pluginCheck.checkName, pluginCheck.checkFn, pluginCheck.time);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
this.servicesMonitor.startMonitor();
|
this.servicesMonitor.startMonitor();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@ var Plugin = function(options) {
|
|||||||
this.contractsConfigs = [];
|
this.contractsConfigs = [];
|
||||||
this.contractsFiles = [];
|
this.contractsFiles = [];
|
||||||
this.compilers = [];
|
this.compilers = [];
|
||||||
|
this.serviceChecks = [];
|
||||||
this.pluginTypes = [];
|
this.pluginTypes = [];
|
||||||
this.logger = options.logger;
|
this.logger = options.logger;
|
||||||
this.events = options.events;
|
this.events = options.events;
|
||||||
@ -98,6 +99,11 @@ Plugin.prototype.registerConsoleCommand = function(cb) {
|
|||||||
this.pluginTypes.push('console');
|
this.pluginTypes.push('console');
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Plugin.prototype.registerServiceCheck = function(checkName, checkFn, time) {
|
||||||
|
this.serviceChecks.push({checkName: checkName, checkFn: checkFn, time: time});
|
||||||
|
this.pluginTypes.push('serviceChecks');
|
||||||
|
};
|
||||||
|
|
||||||
Plugin.prototype.has = function(pluginType) {
|
Plugin.prototype.has = function(pluginType) {
|
||||||
return this.pluginTypes.indexOf(pluginType) >= 0;
|
return this.pluginTypes.indexOf(pluginType) >= 0;
|
||||||
};
|
};
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
"buildDir": "dist/",
|
"buildDir": "dist/",
|
||||||
"config": "config/",
|
"config": "config/",
|
||||||
"plugins": {
|
"plugins": {
|
||||||
"embark-babel": {"files": ["**/*.js", "**/*.jsx", "!**/_vendor/*.js"]}
|
"embark-babel": {"files": ["**/*.js", "**/*.jsx", "!**/_vendor/*.js"]},
|
||||||
|
"embark-service": {}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
5
test_app/extensions/embark-service/index.js
Normal file
5
test_app/extensions/embark-service/index.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = function(embark) {
|
||||||
|
embark.registerServiceCheck('PluginService', function(cb) {
|
||||||
|
cb({name: "ServiceName", status: "green"});
|
||||||
|
});
|
||||||
|
};
|
11
test_app/extensions/embark-service/package.json
Normal file
11
test_app/extensions/embark-service/package.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"name": "embark-service",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"description": "",
|
||||||
|
"main": "index.js",
|
||||||
|
"scripts": {
|
||||||
|
"test": "echo \"Error: no test specified\" && exit 1"
|
||||||
|
},
|
||||||
|
"author": "",
|
||||||
|
"license": "ISC"
|
||||||
|
}
|
@ -15,6 +15,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"embark-babel": "^1.0.0",
|
"embark-babel": "^1.0.0",
|
||||||
|
"embark-service": "./extensions/embark-service",
|
||||||
"ethereumjs-testrpc": "^3.0.3"
|
"ethereumjs-testrpc": "^3.0.3"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user