DB 작업용 신규 워커 추가.

This commit is contained in:
2025-12-11 14:35:27 +09:00
parent 9aaa4670ae
commit 632f834ac5
3 changed files with 167 additions and 5 deletions

View File

@@ -58,6 +58,7 @@ namespace TriliumMind
// Register Workers
builder.Services.AddHostedService<JiraWorker>();
builder.Services.AddHostedService<TriliumWorker>();
builder.Services.AddHostedService<AppDbWorker>();
// Register Channels
builder.Services.AddSingleton(Channel.CreateUnbounded<Issue>());
@@ -69,12 +70,19 @@ namespace TriliumMind
Log.Information("Starting database migration...");
using var scope = host.Services.CreateScope();
var db = scope.ServiceProvider.GetRequiredService<AppDbService>();
await db.InitializeDatabaseAsync();
var dbContext = scope.ServiceProvider.GetRequiredService<IAppDbContext>();
if(dbContext is DbContext context)
{
var created = await context.Database.EnsureCreatedAsync();
if(created)
Log.Information("Database created successfully");
else
Log.Information("Database already exists");
}
var dbService = scope.ServiceProvider.GetRequiredService<AppDbService>();
var appCoinfigs = host.Services.GetRequiredService<AppConfigs>();
appCoinfigs.RuntimeConfigs = await db.LoadConfigAsync();
appCoinfigs.RuntimeConfigs = await dbService.LoadConfigAsync();
Log.Information("Database initialization completed successfully");
}