diff --git a/lib/core/engine.js b/lib/core/engine.js index 856593d5..9f7a8736 100644 --- a/lib/core/engine.js +++ b/lib/core/engine.js @@ -37,6 +37,15 @@ Engine.prototype.init = function(_options) { }; 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(); }; diff --git a/lib/core/plugin.js b/lib/core/plugin.js index 9d6ff37a..45a498f0 100644 --- a/lib/core/plugin.js +++ b/lib/core/plugin.js @@ -17,6 +17,7 @@ var Plugin = function(options) { this.contractsConfigs = []; this.contractsFiles = []; this.compilers = []; + this.serviceChecks = []; this.pluginTypes = []; this.logger = options.logger; this.events = options.events; @@ -98,6 +99,11 @@ Plugin.prototype.registerConsoleCommand = function(cb) { 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) { return this.pluginTypes.indexOf(pluginType) >= 0; }; diff --git a/test_app/embark.json b/test_app/embark.json index 5cdaae97..0dd46dd1 100644 --- a/test_app/embark.json +++ b/test_app/embark.json @@ -14,6 +14,7 @@ "buildDir": "dist/", "config": "config/", "plugins": { - "embark-babel": {"files": ["**/*.js", "**/*.jsx", "!**/_vendor/*.js"]} + "embark-babel": {"files": ["**/*.js", "**/*.jsx", "!**/_vendor/*.js"]}, + "embark-service": {} } } diff --git a/test_app/extensions/embark-service/index.js b/test_app/extensions/embark-service/index.js new file mode 100644 index 00000000..27f58c84 --- /dev/null +++ b/test_app/extensions/embark-service/index.js @@ -0,0 +1,5 @@ +module.exports = function(embark) { + embark.registerServiceCheck('PluginService', function(cb) { + cb({name: "ServiceName", status: "green"}); + }); +}; diff --git a/test_app/extensions/embark-service/package.json b/test_app/extensions/embark-service/package.json new file mode 100644 index 00000000..b20033a1 --- /dev/null +++ b/test_app/extensions/embark-service/package.json @@ -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" +} diff --git a/test_app/package.json b/test_app/package.json index 042f454f..d1ea282a 100644 --- a/test_app/package.json +++ b/test_app/package.json @@ -15,6 +15,7 @@ }, "dependencies": { "embark-babel": "^1.0.0", + "embark-service": "./extensions/embark-service", "ethereumjs-testrpc": "^3.0.3" } }