mirror of https://github.com/embarklabs/embark.git
warn if server is already running or not
This commit is contained in:
parent
14d330a729
commit
8360295ed0
|
@ -12,6 +12,13 @@ class Server {
|
|||
}
|
||||
|
||||
start(callback) {
|
||||
if (this.server && this.server.listening) {
|
||||
this.logger.warn("a webserver is already running at " + ("http://" + this.hostname + ":" + this.port).bold.underline.green);
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
return;
|
||||
}
|
||||
let serve = serveStatic(this.dist, {'index': ['index.html', 'index.htm']});
|
||||
|
||||
this.server = http.createServer(function onRequest(req, res) {
|
||||
|
@ -26,6 +33,13 @@ class Server {
|
|||
}
|
||||
|
||||
stop(callback) {
|
||||
if (!this.server || !this.server.listening) {
|
||||
this.logger.warn("no webserver is currently running");
|
||||
if (callback) {
|
||||
callback();
|
||||
}
|
||||
return;
|
||||
}
|
||||
this.server.shutdown(function() {
|
||||
if (callback) {
|
||||
callback();
|
||||
|
|
Loading…
Reference in New Issue