fix: 修复服务启动时的竞态条件,等待健康检查通过后再报告就绪
This commit is contained in:
@@ -125,7 +125,22 @@ class XCOpenCodeWebService {
|
||||
this.processPid = null;
|
||||
});
|
||||
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, 2000));
|
||||
const maxWaitTime = 30000;
|
||||
const checkInterval = 500;
|
||||
const startTime = Date.now();
|
||||
|
||||
while (Date.now() - startTime < maxWaitTime) {
|
||||
const isHealthy = await this.checkHealth();
|
||||
if (isHealthy) {
|
||||
break;
|
||||
}
|
||||
await new Promise<void>((resolve) => setTimeout(resolve, checkInterval));
|
||||
}
|
||||
|
||||
const finalHealth = await this.checkHealth();
|
||||
if (!finalHealth) {
|
||||
log.warn('[XCOpenCodeWebService] Health check failed after max wait time');
|
||||
}
|
||||
|
||||
this._isRunning = true;
|
||||
this._isStarting = false;
|
||||
|
||||
Reference in New Issue
Block a user