Revert "diag: AddConsul前后读配置值,定位 Winton 是否注入 IConfiguration"
This reverts commit 4883b44d33075cb12b46f97335e085f9ace0d25d.
This commit is contained in:
parent
4883b44d33
commit
78d9bcb5b2
@ -32,22 +32,19 @@ builder.Configuration.AddConsul(
|
||||
// 默认 ConvertConsulKVPairToConfig 把 Consul key 路径(去 buildflow/ 前缀,/ 转 :)作为 IConfiguration key,
|
||||
// 如 buildflow/Jwt:SigningKey → 配置 Jwt:SigningKey,value 直接是密钥字符串。
|
||||
options.Parser = new SimpleConfigurationParser();
|
||||
options.Optional = false; // 诊断:Consul 必须可用,暴露真实问题
|
||||
options.Optional = false; // 诊断期:强制 Consul 必须可用,暴露真实错误
|
||||
options.ReloadOnChange = true; // KV 变更自动刷新 IConfiguration(热重载基础)
|
||||
// 诊断期:打印 Consul 加载异常(确认后改回 Ignore)
|
||||
options.OnLoadException = ex =>
|
||||
{
|
||||
// Consul 加载失败只告警不崩溃(本地开发/CI 可能无 Consul token)
|
||||
Console.WriteLine($"[Consul] 加载异常(已忽略,回退本地配置): {ex.Exception?.Message}");
|
||||
ex.Ignore = true;
|
||||
Console.WriteLine($"[Consul] 加载异常: {ex.Exception?.GetType().Name}: {ex.Exception?.Message}");
|
||||
Console.WriteLine($"[Consul] 堆栈: {ex.Exception?.StackTrace?.Substring(0, System.Math.Min(500, ex.Exception?.StackTrace?.Length ?? 0))}");
|
||||
ex.Ignore = false; // 不吞,让异常抛出
|
||||
};
|
||||
});
|
||||
|
||||
// OTel 日志导出
|
||||
var otlpEndpoint = builder.Configuration["OpenTelemetry:OtlpEndpoint"] ?? "http://localhost:4316";
|
||||
|
||||
// ★ 诊断:AddConsul 之后立即读 KV 值,确认是否进入 IConfiguration(Build 前)
|
||||
Console.WriteLine($"[DIAG] AddConsul后读 PollInterval={builder.Configuration["Monitoring:Scheduler:PollIntervalSeconds"]}(999=KV生效,60=本地)");
|
||||
Console.WriteLine($"[DIAG] Jwt:SigningKey={builder.Configuration["Jwt:SigningKey"]?[..10]}...");
|
||||
builder.Logging.AddOpenTelemetry(logging =>
|
||||
{
|
||||
logging.AddOtlpExporter(options => options.Endpoint = new Uri(otlpEndpoint));
|
||||
@ -60,9 +57,6 @@ builder.Services.AddHostObjectAccessors();
|
||||
await builder.AddApplicationAsync<BuildFlowHostModule>();
|
||||
|
||||
var app = builder.Build();
|
||||
// ★ 诊断:Build 后再读一次(Winton Load 在 Build 时触发)
|
||||
Console.WriteLine($"[DIAG] Build后读 PollInterval={app.Configuration["Monitoring:Scheduler:PollIntervalSeconds"]}");
|
||||
Console.WriteLine($"[DIAG] Build后读 SigningKey={app.Configuration["Jwt:SigningKey"]?[..10]}...");
|
||||
await app.InitializeApplicationAsync();
|
||||
|
||||
// 启动期数据库初始化:迁移各库 + IM MongoDB 建索引 + 种子数据(单库失败不影响其他库)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user