check port for webserver, if in use ++ port
This commit is contained in:
parent
fa551f67a3
commit
a38c317ecd
|
@ -17,14 +17,20 @@ class WebServer {
|
||||||
this.port = options.port || this.webServerConfig.port;
|
this.port = options.port || this.webServerConfig.port;
|
||||||
|
|
||||||
this.events.emit("status", __("Starting Server"));
|
this.events.emit("status", __("Starting Server"));
|
||||||
this.server = new Server({host: this.host, port: this.port});
|
|
||||||
|
|
||||||
this.setServiceCheck();
|
utils.pingEndpoint(this.host, this.port, 'http', 'http', '', (err) => {
|
||||||
this.listenToCommands();
|
if (!err) { // Port already in use
|
||||||
this.registerConsoleCommands();
|
this.logger.warn(__('Webserver already running on port {{oldPort}}. Trying to connect on {{newPort}}',
|
||||||
|
{oldPort: this.port, newPort: this.port + 1}));
|
||||||
|
this.port++;
|
||||||
|
}
|
||||||
|
this.server = new Server({host: this.host, port: this.port});
|
||||||
|
|
||||||
let self = this;
|
this.setServiceCheck();
|
||||||
this.server.start((_err, message) => self.logger.info(message));
|
this.listenToCommands();
|
||||||
|
this.registerConsoleCommands();
|
||||||
|
this.server.start((_err, message) => this.logger.info(message));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
setServiceCheck() {
|
setServiceCheck() {
|
||||||
|
|
Loading…
Reference in New Issue