mirror of https://github.com/embarklabs/embark.git
move webserver cmds to module
This commit is contained in:
parent
411ed41c84
commit
92de2904f1
|
@ -43,12 +43,6 @@ class Console {
|
|||
return text.join('\n');
|
||||
} else if (['quit', 'exit', 'sair', 'sortir'].indexOf(cmd) >= 0) {
|
||||
utils.exit();
|
||||
} else if (cmd === 'webserver start') {
|
||||
this.events.request("start-webserver");
|
||||
return " ";
|
||||
} else if (cmd === 'webserver stop') {
|
||||
this.events.request("stop-webserver");
|
||||
return "stopping webserver...";
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ var Server = require('./server.js');
|
|||
class WebServer {
|
||||
|
||||
constructor(embark, options) {
|
||||
this.embark = embark;
|
||||
this.logger = embark.logger;
|
||||
this.events = embark.events;
|
||||
this.addCheck = options.addCheck;
|
||||
|
@ -20,6 +21,7 @@ class WebServer {
|
|||
|
||||
this.setServiceCheck();
|
||||
this.listenToCommands();
|
||||
this.registerConsoleCommands();
|
||||
|
||||
this.server.start();
|
||||
}
|
||||
|
@ -46,6 +48,21 @@ class WebServer {
|
|||
this.events.setCommandHandler('stop-webserver', () => { this.server.stop(); });
|
||||
}
|
||||
|
||||
registerConsoleCommands() {
|
||||
const self = this;
|
||||
self.embark.registerConsoleCommand((cmd, options) => {
|
||||
if (cmd === 'webserver start') {
|
||||
self.events.request("start-webserver");
|
||||
return " ";
|
||||
}
|
||||
if (cmd === 'webserver stop') {
|
||||
self.events.request("stop-webserver");
|
||||
return "stopping webserver...";
|
||||
}
|
||||
return false;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
module.exports = WebServer;
|
||||
|
|
Loading…
Reference in New Issue