refactor(modules/webserver): use ProcessManager APIs to start and stop the server
This commit is contained in:
parent
188a688264
commit
3dd28b9459
|
@ -26,6 +26,11 @@ class WebServer {
|
|||
this.enableCatchAll = this.webServerConfig.enableCatchAll === true;
|
||||
this.enableCatchAll = false; // FIXME when true, some Requests end up failing (eg: process-logs)
|
||||
|
||||
this.events.request('processes:register', 'webserver', {
|
||||
launchFn: (cb) => { this.server.start(cb) },
|
||||
stopFn: (cb) => { this.server.stop(cb) }
|
||||
});
|
||||
|
||||
this.events.emit("status", __("Starting Server"));
|
||||
|
||||
this.server = new Server({
|
||||
|
@ -52,8 +57,8 @@ class WebServer {
|
|||
this.server.port = this.port;
|
||||
|
||||
this.testPort(() => {
|
||||
this.server.stop((_err) => {
|
||||
this.server.start((_err, message, port) => {
|
||||
this.events.request('processes:stop', 'webserver', _err => {
|
||||
this.events.request('processes:launch', 'webserver', (_err, message, port) => {
|
||||
this.logger.info(message);
|
||||
this.port = port;
|
||||
this.events.request('open-browser', () => {});
|
||||
|
@ -63,7 +68,7 @@ class WebServer {
|
|||
});
|
||||
|
||||
this.testPort(() => {
|
||||
this.server.start((_err, message, port) => {
|
||||
this.events.request('processes:launch', 'webserver', (_err, message, port) => {
|
||||
this.logger.info(message);
|
||||
this.port = port;
|
||||
this.setServiceCheck();
|
||||
|
@ -108,8 +113,8 @@ class WebServer {
|
|||
listenToCommands() {
|
||||
this.events.setCommandHandler('build-placeholder', (cb) => this.buildPlaceholderPage(cb));
|
||||
this.events.setCommandHandler('open-browser', (cb) => this.openBrowser(cb));
|
||||
this.events.setCommandHandler('start-webserver', (cb) => this.server.start(cb));
|
||||
this.events.setCommandHandler('stop-webserver', (cb) => this.server.stop(cb));
|
||||
this.events.setCommandHandler('start-webserver', (cb) => this.events.request('processes:launch', 'webserver', cb));
|
||||
this.events.setCommandHandler('stop-webserver', (cb) => this.events.request('processes:stop', 'webserver', cb));
|
||||
this.events.setCommandHandler('logs:webserver:turnOn', (cb) => this.server.enableLogging(cb));
|
||||
this.events.setCommandHandler('logs:webserver:turnOff', (cb) => this.server.disableLogging(cb));
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue