check port for webserver, if in use ++ port

This commit is contained in:
Jonathan Rainville 2018-08-23 14:14:10 -04:00
parent fa551f67a3
commit a38c317ecd
1 changed files with 12 additions and 6 deletions

View File

@ -17,14 +17,20 @@ class WebServer {
this.port = options.port || this.webServerConfig.port;
this.events.emit("status", __("Starting Server"));
utils.pingEndpoint(this.host, this.port, 'http', 'http', '', (err) => {
if (!err) { // Port already in use
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});
this.setServiceCheck();
this.listenToCommands();
this.registerConsoleCommands();
let self = this;
this.server.start((_err, message) => self.logger.info(message));
this.server.start((_err, message) => this.logger.info(message));
});
}
setServiceCheck() {