refactor(core/engine): make serviceMonitor a module group

`Engine`s internal `coreComponents()` API sets up a bunch of things like
a `ProcessManager` and the `ServiceMonitor`. The `ServiceMonitor` activates
itself on `embark:engine:started` and practically monitors registered services
until the process has been explicitly stopped.

There are some commands that don't actually need service monitoring like `build` and
a future `exec` command that's in the making. For those cases it's useful to have them
disable the service monitor when `coreComponents()` is used.

This commit moves the `ServiceMonitor` instantiation out of `coreComponents()` and introduces
a new module group instead. This then lets commands that need service monitoring instantiate it
explicitly.
This commit is contained in:
Pascal Precht 2020-01-30 13:25:52 +01:00 committed by Pascal Precht
parent d4136ffa8a
commit 88c8135d9c
2 changed files with 15 additions and 9 deletions

View File

@ -155,6 +155,7 @@ export class Engine {
blockchain: this.blockchainComponents,
coreComponents: this.coreComponents,
stackComponents: this.stackComponents,
serviceMonitor: this.serviceMonitor,
consoleComponents: this.consoleComponents,
blockchainStackComponents: this.blockchainStackComponents,
compiler: this.compilerComponents,
@ -196,15 +197,7 @@ export class Engine {
});
}
coreComponents() {
// TODO: should be made into a component
this.processManager = new ProcessManager({
events: this.events,
logger: this.logger,
plugins: this.plugins
});
serviceMonitor(options) {
this.servicesMonitor = new ServicesMonitor({ events: this.events, logger: this.logger, plugins: this.plugins });
if (this.servicesMonitor) {
@ -220,6 +213,16 @@ export class Engine {
});
}
}
}
coreComponents(options) {
// TODO: should be made into a component
this.processManager = new ProcessManager({
events: this.events,
logger: this.logger,
plugins: this.plugins
});
this.registerModulePackage('embark-code-runner', { ipc: this.ipc });

View File

@ -61,6 +61,7 @@ class EmbarkController {
Object.assign(engine.config.blockchainConfig, { isStandalone: true });
engine.registerModuleGroup("coreComponents");
engine.registerModuleGroup("serviceMonitor");
engine.registerModuleGroup("blockchainStackComponents");
engine.registerModuleGroup("blockchain");
@ -160,6 +161,7 @@ class EmbarkController {
function (callback) {
engine.registerModuleGroup("coreComponents");
engine.registerModuleGroup("serviceMonitor");
engine.registerModuleGroup("stackComponents");
engine.registerModuleGroup("consoleComponents");
@ -375,6 +377,7 @@ class EmbarkController {
},
callback => {
engine.registerModuleGroup("coreComponents");
engine.registerModuleGroup("serviceMonitor");
engine.registerModuleGroup("stackComponents");
engine.registerModuleGroup("consoleComponents");