Skip to content

Commit 88c8135

Browse files
committed
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.
1 parent d4136ff commit 88c8135

File tree

2 files changed

+15
-9
lines changed

2 files changed

+15
-9
lines changed

packages/core/engine/src/index.ts

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ export class Engine {
155155
blockchain: this.blockchainComponents,
156156
coreComponents: this.coreComponents,
157157
stackComponents: this.stackComponents,
158+
serviceMonitor: this.serviceMonitor,
158159
consoleComponents: this.consoleComponents,
159160
blockchainStackComponents: this.blockchainStackComponents,
160161
compiler: this.compilerComponents,
@@ -196,15 +197,7 @@ export class Engine {
196197
});
197198
}
198199

199-
coreComponents() {
200-
201-
// TODO: should be made into a component
202-
this.processManager = new ProcessManager({
203-
events: this.events,
204-
logger: this.logger,
205-
plugins: this.plugins
206-
});
207-
200+
serviceMonitor(options) {
208201
this.servicesMonitor = new ServicesMonitor({ events: this.events, logger: this.logger, plugins: this.plugins });
209202

210203
if (this.servicesMonitor) {
@@ -220,6 +213,16 @@ export class Engine {
220213
});
221214
}
222215
}
216+
}
217+
218+
coreComponents(options) {
219+
220+
// TODO: should be made into a component
221+
this.processManager = new ProcessManager({
222+
events: this.events,
223+
logger: this.logger,
224+
plugins: this.plugins
225+
});
223226

224227
this.registerModulePackage('embark-code-runner', { ipc: this.ipc });
225228

packages/embark/src/cmd/cmd_controller.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ class EmbarkController {
6161
Object.assign(engine.config.blockchainConfig, { isStandalone: true });
6262

6363
engine.registerModuleGroup("coreComponents");
64+
engine.registerModuleGroup("serviceMonitor");
6465
engine.registerModuleGroup("blockchainStackComponents");
6566
engine.registerModuleGroup("blockchain");
6667

@@ -160,6 +161,7 @@ class EmbarkController {
160161
function (callback) {
161162

162163
engine.registerModuleGroup("coreComponents");
164+
engine.registerModuleGroup("serviceMonitor");
163165
engine.registerModuleGroup("stackComponents");
164166
engine.registerModuleGroup("consoleComponents");
165167

@@ -375,6 +377,7 @@ class EmbarkController {
375377
},
376378
callback => {
377379
engine.registerModuleGroup("coreComponents");
380+
engine.registerModuleGroup("serviceMonitor");
378381
engine.registerModuleGroup("stackComponents");
379382
engine.registerModuleGroup("consoleComponents");
380383

0 commit comments

Comments
 (0)