fix(backend): eagerly resolve PolicyRunner at startup for fail-fast on missing ONNX
This commit is contained in:
@@ -17,6 +17,15 @@ builder.Services.AddSingleton<PolicyRunner>(sp =>
|
||||
builder.Services.AddLogging();
|
||||
|
||||
var app = builder.Build();
|
||||
|
||||
// Fail-fast: eagerly resolve PolicyRunner so a missing ONNX file surfaces at
|
||||
// startup rather than on the first WebSocket connect.
|
||||
var startupLogger = app.Services.GetRequiredService<ILoggerFactory>().CreateLogger("Startup");
|
||||
var policy = app.Services.GetRequiredService<PolicyRunner>();
|
||||
var modelPath = PathResolver.Resolve(
|
||||
app.Services.GetRequiredService<Microsoft.Extensions.Options.IOptions<LanderConfig>>().Value.ModelPath);
|
||||
startupLogger.LogInformation("Loaded PPO policy from {ModelPath}", modelPath);
|
||||
|
||||
app.UseWebSockets();
|
||||
|
||||
// -------- Health --------
|
||||
|
||||
Reference in New Issue
Block a user