Skip to content

Commit a9d1788

Browse files
deansheathercode-asher
authored andcommitted
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.
1 parent cf63bbd commit a9d1788

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

packages/server/src/cli.ts

+13-6
Original file line numberDiff line numberDiff line change
@@ -279,10 +279,11 @@ const bold = (text: string | number): string | number => {
279279
} : undefined,
280280
});
281281

282-
logger.info("Starting webserver...", field("host", options.host), field("port", options.port));
283282
if (options.socket) {
283+
logger.info("Starting webserver via socket...", field("socket", options.socket));
284284
app.server.listen(options.socket);
285285
} else {
286+
logger.info("Starting webserver...", field("host", options.host), field("port", options.port));
286287
app.server.listen(options.port, options.host);
287288
}
288289
let clientId = 1;
@@ -323,14 +324,20 @@ const bold = (text: string | number): string | number => {
323324
logger.warn("Launched without authentication.");
324325
}
325326
if (options.disableTelemetry) {
326-
logger.info("Telemetry is disabled");
327+
logger.info(" ");
328+
logger.info("Telemetry is disabled.");
327329
}
328330

329-
const protocol = options.allowHttp ? "http" : "https";
330-
const url = `${protocol}://localhost:${options.port}/`;
331331
logger.info(" ");
332-
logger.info("Started (click the link below to open):");
333-
logger.info(url);
332+
if (options.socket) {
333+
logger.info("Started on socket address:");
334+
logger.info(options.socket);
335+
} else {
336+
const protocol = options.allowHttp ? "http" : "https";
337+
const url = `${protocol}://localhost:${app.server.address().port}/`;
338+
logger.info("Started (click the link below to open):");
339+
logger.info(url);
340+
}
334341
logger.info(" ");
335342

336343
if (options.open) {

0 commit comments

Comments
 (0)