fix: GetFreePort() will get the same port (#18604)

This commit is contained in:
jiuker
2023-12-07 02:36:42 +08:00
committed by GitHub
parent 4bc5ed6c76
commit 5cc2c62c66

View File

@@ -388,6 +388,11 @@ func handleCommonCmdArgs(ctx *cli.Context) {
if err != nil {
logger.FatalIf(err, "Unable to get free port for Console UI on the host")
}
// hold the port
l, err := net.Listen("TCP", fmt.Sprintf(":%s", p.String()))
if err == nil {
defer l.Close()
}
consoleAddr = net.JoinHostPort("", p.String())
}