embark/lib/core
Pascal Precht 64d8fa3368
feat(core/processManager): introduce `processes:stop` handlers
So far, `ProcessManager` was able to only register a `process:launch` handler.
There was no way to tell `ProcessManager` how to stop processes. This hasn't
been a problem so far as most of the service processes can be started without the usage
of the `ProcessManager`, but turns out to be necessary if we want Embark UI to be able
to pick up running services.

A good example is the webserver process, which until now bypasses the `ProcessManager`
all together. The webserver sets up two event handlers to start and stop it respectively:

```
this.events.setCommandHandler('start-webserver', () => this.server.start());
this.events.setCommandHandler('stop-webserver', () => this.server.stop());
```

In the future, this should happen through the `ProcessManager` instead, so the webserver
process can be picked up by Embark UI, like this:

```
this.request('process:register', 'webserver', () => {
  this.server.start();
});

// and then

this.request('process:launch', 'webserver', () => {
  // server started
});
```

Notice that the given callback to registering a process is actually the function that
gets called to launch the process.

Having that in mind, and considering that we also need a way to stop the process through
`ProcessManager, so we don't introduce a regression, we need a way to register a stop
call back as well.

The new API introduced in this commit looks like this:

```
this.request('process:register', 'webserver', {
  launchFn: (callback) => { this.server.start(callback) },
  stopFn: (callback) => this.server.stop(callback) }
});

// and then

this.request('process:launch', 'webserver', (err, message, port) => {
  // server started
});

this.request('process:stop', 'webserver', err => {
  // server stopped
});
```

Notice that `process:register` works exactly the same way as before as well.

Another thing to notice is that all parameters emitted by the underlying process
are propagated to the outside caller, which is why `err`, `message` and `port` are
available inside the launch callback.
2018-10-23 10:57:05 +02:00
..
i18n use console.warn and yellow text for locale fallback msg 2018-08-23 15:00:25 -05:00
modules/coderunner rebase fixes 2018-10-23 10:34:46 +02:00
processes feat(core/processManager): introduce `processes:stop` handlers 2018-10-23 10:57:05 +02:00
config.js cherry-pick features/react-routes 2018-10-23 10:21:39 +02:00
core.js migrate all the code to ES6 2017-03-30 20:12:39 +09:00
engine.js Addressed PR comments 2018-10-23 10:57:04 +02:00
events.js first stab at refactor blockchain launcher 2018-10-23 09:55:10 +02:00
file.js Add remapping when parse file to support embark-solc 2018-10-22 19:25:19 +02:00
fs.js Overwrite log file so .embark doesn’t bloat 2018-10-23 10:54:35 +02:00
ipc.js revert caca code 2018-10-23 10:03:25 +02:00
logger.js Rebase updates 2018-10-23 10:57:04 +02:00
plugin.js remove unneded console logs 2018-10-23 10:50:37 +02:00
plugins.js Add plugins and versions to backend tab 2018-10-23 10:32:02 +02:00
services_monitor.js fix blockchain already booted 2018-06-05 14:39:18 -04:00