Browse Source

启动网络方式 主次换一个位置

feature/protocol-log-Perfect
root 3 days ago
parent
commit
139e115f5a
  1. 32
      CoreAgent.Infrastructure/Services/Network/NetworkInterfaceManager.cs

32
CoreAgent.Infrastructure/Services/Network/NetworkInterfaceManager.cs

@ -273,6 +273,22 @@ public class NetworkInterfaceManager : INetworkInterfaceManager
private async Task<NetworkInterfaceOperationResult> ExecuteMultiConfigStartCommandsAsync(CommandTemplateConfig startCommand, NetworkConfiguration networkConfig) private async Task<NetworkInterfaceOperationResult> ExecuteMultiConfigStartCommandsAsync(CommandTemplateConfig startCommand, NetworkConfiguration networkConfig)
{ {
// 执行主配置命令
var primaryConfig = networkConfig.CoreOrImsConfigs.FirstOrDefault(s => s.Index == 1);
if (primaryConfig != null)
{
var primaryCommand = string.Format(startCommand.Template, 1);
var fullCommand = $"{primaryCommand} {networkConfig.RagConfig} {primaryConfig.CoreNetworkConfig} {primaryConfig.ImsConfig}";
_logger.LogInformation("执行主配置启动命令: {Command}", fullCommand);
//_context.TokenSource
var result = await _commandExecutor.ExecuteCommandAsync(fullCommand, new CancellationTokenSource());
if (!result.IsSuccess)
{
return NetworkInterfaceOperationResult.Failure($"主配置命令执行失败: {result.Error}", NetworkConfigType.BothRagAndCore);
}
}
// 添加次要配置命令 // 添加次要配置命令
var secondaryConfigs = networkConfig.CoreOrImsConfigs.Where(s => s.Index != 1).ToArray(); var secondaryConfigs = networkConfig.CoreOrImsConfigs.Where(s => s.Index != 1).ToArray();
var secondaryTasks = new List<Task<CommandExecutionResult>>(); var secondaryTasks = new List<Task<CommandExecutionResult>>();
@ -295,22 +311,6 @@ public class NetworkInterfaceManager : INetworkInterfaceManager
return NetworkInterfaceOperationResult.Failure("部分次要配置命令执行失败", NetworkConfigType.BothRagAndCore); return NetworkInterfaceOperationResult.Failure("部分次要配置命令执行失败", NetworkConfigType.BothRagAndCore);
} }
// 执行主配置命令
var primaryConfig = networkConfig.CoreOrImsConfigs.FirstOrDefault(s => s.Index == 1);
if (primaryConfig != null)
{
var primaryCommand = string.Format(startCommand.Template, 1);
var fullCommand = $"{primaryCommand} {networkConfig.RagConfig} {primaryConfig.CoreNetworkConfig} {primaryConfig.ImsConfig}";
_logger.LogInformation("执行主配置启动命令: {Command}", fullCommand);
//_context.TokenSource
var result = await _commandExecutor.ExecuteCommandAsync(fullCommand, new CancellationTokenSource());
if (!result.IsSuccess)
{
return NetworkInterfaceOperationResult.Failure($"主配置命令执行失败: {result.Error}", NetworkConfigType.BothRagAndCore);
}
}
return NetworkInterfaceOperationResult.Success(NetworkConfigType.BothRagAndCore); return NetworkInterfaceOperationResult.Success(NetworkConfigType.BothRagAndCore);
} }
} }
Loading…
Cancel
Save