Skip to content

Commit

Permalink
refactor(core/engine): make serviceMonitor a module group
Browse files Browse the repository at this point in the history
`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.
  • Loading branch information
0x-r4bbit committed Feb 4, 2020
1 parent 5b988ea commit 7f311f3
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
21 changes: 12 additions & 9 deletions packages/core/engine/src/index.ts
Expand Up @@ -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,
Expand Down Expand Up @@ -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) {
Expand All @@ -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 });

Expand Down
3 changes: 3 additions & 0 deletions packages/embark/src/cmd/cmd_controller.js
Expand Up @@ -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");

Expand Down Expand Up @@ -160,6 +161,7 @@ class EmbarkController {
function (callback) {

engine.registerModuleGroup("coreComponents");
engine.registerModuleGroup("serviceMonitor");
engine.registerModuleGroup("stackComponents");
engine.registerModuleGroup("consoleComponents");

Expand Down Expand Up @@ -374,6 +376,7 @@ class EmbarkController {
},
callback => {
engine.registerModuleGroup("coreComponents");
engine.registerModuleGroup("serviceMonitor");
engine.registerModuleGroup("stackComponents");
engine.registerModuleGroup("consoleComponents");

Expand Down

0 comments on commit 7f311f3

Please sign in to comment.