Let OS select random open port.

pull/144/head
Mikunj 6 years ago
parent 8c9b1a7a7a
commit f21d1f65e6

@ -54,7 +54,7 @@ class LocalLokiServer extends EventEmitter {
if (err) {
rej(err);
} else {
res(port);
res(this.server.address().port);
}
});
});
@ -70,6 +70,14 @@ class LocalLokiServer extends EventEmitter {
return Promise.resolve();
}
getPort() {
if (this.server.listening) {
return this.server.address().port;
}
return null;
}
}
exports.LocalLokiServer = LocalLokiServer;

@ -84,7 +84,13 @@ MessageReceiver.prototype.extend({
this.localServer.removeAllListeners();
this.localServer.on('message', this.httpPollingResource.handleMessage);
this.localServer.start(8000);
// Passing 0 as the port will automatically assign an unused port
this.localServer
.start(0)
.then(port =>
window.log.info(`Local Server started at https://localhost:${port}`)
);
// TODO: Rework this socket stuff to work with online messaging
const useWebSocket = false;

Loading…
Cancel
Save