fix: reserve web ui port for gateways (#746)
This commit is contained in:
@@ -49,6 +49,7 @@ const execFileAsync = promisify(execFile)
|
||||
|
||||
const HERMES_BASE = detectHermesHome()
|
||||
const HERMES_BIN = getHermesBin()
|
||||
const DEFAULT_WEB_UI_PORT = 8648
|
||||
|
||||
/**
|
||||
* 检测系统的 init 系统(服务管理器)
|
||||
@@ -174,6 +175,11 @@ export function buildGatewayProcessEnv(profileName: string, hermesHome: string):
|
||||
}
|
||||
}
|
||||
|
||||
function getWebUiPort(): number | null {
|
||||
const port = parseInt(process.env.PORT || String(DEFAULT_WEB_UI_PORT), 10)
|
||||
return port > 0 && port <= 65535 ? port : null
|
||||
}
|
||||
|
||||
// ============================
|
||||
// 类型定义
|
||||
// ============================
|
||||
@@ -472,6 +478,8 @@ export class GatewayManager {
|
||||
usedPorts.add(gw.port)
|
||||
}
|
||||
}
|
||||
const webUiPort = getWebUiPort()
|
||||
if (webUiPort !== null) usedPorts.add(webUiPort)
|
||||
|
||||
const port = await this.findFreePort(8642, host, usedPorts)
|
||||
if (configuredPort !== port) {
|
||||
|
||||
Reference in New Issue
Block a user