use port from server.address() when printing URL (#780)

This allows the use of port 0, which is interpretted automatically to
mean "random port".

Additional logging consistency fixes.
This commit is contained in:
Dean Sheather 2019-06-17 17:20:20 +00:00 committed by Asher
parent cf63bbd003
commit a9d17882e7
1 changed files with 13 additions and 6 deletions

View File

@ -279,10 +279,11 @@ const bold = (text: string | number): string | number => {
} : undefined,
});
logger.info("Starting webserver...", field("host", options.host), field("port", options.port));
if (options.socket) {
logger.info("Starting webserver via socket...", field("socket", options.socket));
app.server.listen(options.socket);
} else {
logger.info("Starting webserver...", field("host", options.host), field("port", options.port));
app.server.listen(options.port, options.host);
}
let clientId = 1;
@ -323,14 +324,20 @@ const bold = (text: string | number): string | number => {
logger.warn("Launched without authentication.");
}
if (options.disableTelemetry) {
logger.info("Telemetry is disabled");
logger.info(" ");
logger.info("Telemetry is disabled.");
}
const protocol = options.allowHttp ? "http" : "https";
const url = `${protocol}://localhost:${options.port}/`;
logger.info(" ");
if (options.socket) {
logger.info("Started on socket address:");
logger.info(options.socket);
} else {
const protocol = options.allowHttp ? "http" : "https";
const url = `${protocol}://localhost:${app.server.address().port}/`;
logger.info("Started (click the link below to open):");
logger.info(url);
}
logger.info(" ");
if (options.open) {