新增 Mjpegplayer 用来播放 Web 流
This commit is contained in:
@@ -31,16 +31,14 @@ public static class Bootstrapper
|
||||
"--appid", "CameraApp_01",
|
||||
|
||||
// 视频流地址 (格式: IP,Port,Type,Desc)
|
||||
"--uris", "localhost,9001,video,调试PC;",
|
||||
"--uris", "localhost,9002,video,调试PC-2;",
|
||||
|
||||
// 指令通道
|
||||
"--uris", "localhost,9001,command,调试PC;",
|
||||
|
||||
"--uris", "localhost,9001,调试PC;",
|
||||
"--uris", "localhost,9002,调试PC;",
|
||||
|
||||
// 日志中心配置 (格式: IP,Port,Desc)
|
||||
"--sequris", "58.216.225.5,20026,日志处置中心;",
|
||||
"--seqkey", "Shine899195994250;",
|
||||
|
||||
"--seqkey", "Shine978697953780;",
|
||||
//"--seqkey", "Shine899195994250;",
|
||||
|
||||
// 端口策略
|
||||
"--mode", "1",
|
||||
"--ports", "5000,100"
|
||||
@@ -245,31 +243,71 @@ public static class Bootstrapper
|
||||
if (!config.CommandEndpoints.Any()) return;
|
||||
var gRpcLog = Log.ForContext("SourceContext", LogModules.gRpc);
|
||||
|
||||
try
|
||||
// // Optimized: 并发任务集合,实现多目标同时注册
|
||||
var registrationTasks = config.CommandEndpoints.Select(async endpoint =>
|
||||
{
|
||||
// 将 tcp:// 转换为 http:// 以适配 gRpc
|
||||
string targetUrl = config.CommandEndpoints.First().Uri.Replace("tcp://", "http://");
|
||||
string targetUrl = endpoint.Uri.Replace("tcp://", "http://");
|
||||
|
||||
using var channel = GrpcChannel.ForAddress(targetUrl);
|
||||
var client = new GatewayProvider.GatewayProviderClient(channel);
|
||||
|
||||
gRpcLog.Information($"[gRpc] 正在执行预注册: {targetUrl}");
|
||||
var resp = await client.RegisterInstanceAsync(new RegisterRequest
|
||||
// // Modified: 将 try-catch 移入内部,确保单个端点失败不影响其他端点
|
||||
try
|
||||
{
|
||||
InstanceId = config.AppId,
|
||||
Version = "2.0.0-grpc",
|
||||
ServerIp = "127.0.0.1",
|
||||
WebapiPort = config.BasePort, // 使用扫描后的新端口
|
||||
StartTimeTicks = DateTime.Now.Ticks,
|
||||
ProcessId = Environment.ProcessId,
|
||||
Description = ""
|
||||
});
|
||||
gRpcLog.Information($"[gRpc] 💡预注册成功: {resp.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
gRpcLog.Error($"[gRpc] ⚠️ 预注册尝试失败: {ex.Message}");
|
||||
}
|
||||
using var channel = GrpcChannel.ForAddress(targetUrl);
|
||||
var client = new GatewayProvider.GatewayProviderClient(channel);
|
||||
|
||||
gRpcLog.Information($"[gRpc] 正在执行预注册: {targetUrl}");
|
||||
|
||||
var resp = await client.RegisterInstanceAsync(new RegisterRequest
|
||||
{
|
||||
InstanceId = config.AppId,
|
||||
Version = "2.0.0-grpc",
|
||||
ServerIp = "127.0.0.1",
|
||||
WebapiPort = config.BasePort,
|
||||
StartTimeTicks = DateTime.Now.Ticks,
|
||||
ProcessId = Environment.ProcessId,
|
||||
Description = endpoint.Description // 携带备注信息
|
||||
});
|
||||
|
||||
gRpcLog.Information($"[gRpc] 💡预注册成功: {targetUrl} -> {resp.Message}");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// // Optimized: 记录具体哪个端点失败,但不阻断流程
|
||||
gRpcLog.Error($"[gRpc] ⚠️ 预注册尝试失败 ({targetUrl}): {ex.Message}");
|
||||
}
|
||||
});
|
||||
|
||||
// 等待所有注册任务完成
|
||||
await Task.WhenAll(registrationTasks);
|
||||
|
||||
//try
|
||||
//{
|
||||
// var cfgEndpoints = config.CommandEndpoints;
|
||||
// for(var i=0; i<cfgEndpoints.Count; i++)
|
||||
// {
|
||||
// // 将 tcp:// 转换为 http:// 以适配 gRpc
|
||||
// string targetUrl = cfgEndpoints[i].Uri.Replace("tcp://", "http://");
|
||||
|
||||
// using var channel = GrpcChannel.ForAddress(targetUrl);
|
||||
// var client = new GatewayProvider.GatewayProviderClient(channel);
|
||||
|
||||
// gRpcLog.Information($"[gRpc] 正在执行预注册: {targetUrl}");
|
||||
// var resp = await client.RegisterInstanceAsync(new RegisterRequest
|
||||
// {
|
||||
// InstanceId = config.AppId,
|
||||
// Version = "2.0.0-grpc",
|
||||
// ServerIp = "127.0.0.1",
|
||||
// WebapiPort = config.BasePort, // 使用扫描后的新端口
|
||||
// StartTimeTicks = DateTime.Now.Ticks,
|
||||
// ProcessId = Environment.ProcessId,
|
||||
// Description = ""
|
||||
// });
|
||||
// gRpcLog.Information($"[gRpc] 💡预注册成功: {resp.Message}");
|
||||
// }
|
||||
//}
|
||||
//catch (Exception ex)
|
||||
//{
|
||||
// gRpcLog.Error($"[gRpc] ⚠️ 预注册尝试失败: {ex.Message}");
|
||||
//}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
Reference in New Issue
Block a user