Skip to content

Commit ad3b091

Browse files
author
lrhh123
committed
fix: 修复重启时的端口错误
1 parent 79c24e9 commit ad3b091

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/main/system/backend.ts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,13 @@ class BackendServiceManager {
3535
return;
3636
}
3737

38-
const port = await this.getAvailablePort();
39-
this.port = port;
38+
// 避免重复启动时端口冲突
39+
if (!this.port) {
40+
const port = await this.getAvailablePort();
41+
this.port = port;
42+
}
4043

41-
this.launchProcess(port);
44+
this.launchProcess(this.port);
4245

4346
// 监听退出事件并可能重启
4447
this.process?.on('close', (code) => {

0 commit comments

Comments
 (0)