mirror of https://github.com/embarklabs/embark.git
increment port multiple times if multiple embarks
This commit is contained in:
parent
a38c317ecd
commit
7e59b6f0d0
|
@ -18,12 +18,7 @@ class WebServer {
|
|||
|
||||
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.testPort(() => {
|
||||
this.server = new Server({host: this.host, port: this.port});
|
||||
|
||||
this.setServiceCheck();
|
||||
|
@ -33,6 +28,18 @@ class WebServer {
|
|||
});
|
||||
}
|
||||
|
||||
testPort(done) {
|
||||
utils.pingEndpoint(this.host, this.port, 'http', 'http', '', (err) => {
|
||||
if (err) { // Port is ok
|
||||
return done();
|
||||
}
|
||||
this.logger.warn(__('Webserver already running on port {{oldPort}}. Trying to connect on {{newPort}}',
|
||||
{oldPort: this.port, newPort: this.port + 1}));
|
||||
this.port++;
|
||||
this.testPort(done);
|
||||
});
|
||||
}
|
||||
|
||||
setServiceCheck() {
|
||||
let url = 'http://' + canonicalHost(this.host) + ':' + this.port;
|
||||
|
||||
|
|
Loading…
Reference in New Issue