@@ -1121,6 +1121,25 @@ private async Task StartAllServicesAsync()
11211121 {
11221122 _logger . LogInformation ( "PMHQ 启动成功" ) ;
11231123
1124+ // 先启动 LLBot,确保 WebSocket 服务就绪,避免错过 QQ 事件
1125+ _logger . LogInformation ( "正在启动 LLBot..." ) ;
1126+ var llbotSuccess = await _processManager . StartLLBotAsync (
1127+ config . NodePath ,
1128+ config . LLBotPath ) ;
1129+
1130+ if ( llbotSuccess )
1131+ {
1132+ _logger . LogInformation ( "LLBot 启动成功" ) ;
1133+ IsServicesRunning = true ;
1134+ }
1135+ else
1136+ {
1137+ ErrorMessage = "LLBot 启动失败,请检查日志" ;
1138+ _logger . LogError ( "LLBot 启动失败" ) ;
1139+ BotStatus = ProcessStatus . Stopped ;
1140+ return ;
1141+ }
1142+
11241143 // 设置 PmhqClient 端口并开始轮询
11251144 if ( _processManager . PmhqPort . HasValue )
11261145 {
@@ -1244,30 +1263,10 @@ private async Task StartAllServicesAsync()
12441263
12451264 StartInfoPolling ( ) ;
12461265
1247- // 等待一段时间后启动 LLBot
1248- await Task . Delay ( 2000 ) ;
1266+ BotStatus = ProcessStatus . Running ;
12491267
1250- // 启动 LLBot
1251- _logger . LogInformation ( "正在启动 LLBot..." ) ;
1252- var llbotSuccess = await _processManager . StartLLBotAsync (
1253- config . NodePath ,
1254- config . LLBotPath ) ;
1255-
1256- if ( llbotSuccess )
1257- {
1258- _logger . LogInformation ( "LLBot 启动成功" ) ;
1259- IsServicesRunning = true ;
1260- BotStatus = ProcessStatus . Running ;
1261-
1262- // 执行启动后命令
1263- await ExecuteStartupCommandAsync ( config ) ;
1264- }
1265- else
1266- {
1267- ErrorMessage = "LLBot 启动失败,请检查日志" ;
1268- _logger . LogError ( "LLBot 启动失败" ) ;
1269- BotStatus = ProcessStatus . Stopped ;
1270- }
1268+ // 执行启动后命令
1269+ await ExecuteStartupCommandAsync ( config ) ;
12711270 }
12721271 else
12731272 {
0 commit comments