Skip to content

Commit c825e10

Browse files
committed
feat: Warn user if default port is in use and a different port is used.
1 parent acb8e5c commit c825e10

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

src/lib/port.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
1+
import consola from "consola"
12
import { getPort } from "get-port-please"
23

34
import { configManager } from "./config"
45

56
export async function initializePort(): Promise<number> {
67
const config = configManager.getConfig()
8+
const requestedPort = config.PORT
79

810
const port = await getPort({
911
name: "copilot-api",
@@ -12,6 +14,12 @@ export async function initializePort(): Promise<number> {
1214
random: false,
1315
})
1416

17+
if (port !== requestedPort) {
18+
consola.warn(
19+
`Default port ${requestedPort} is already in use. Using port ${port} instead.`,
20+
)
21+
}
22+
1523
configManager.setConfig({ PORT: port })
1624

1725
return port

0 commit comments

Comments
 (0)