- Fix sort order regression in GetByListIdAsync (was descending, should be ascending) - Restore WAL mode pragma (was silently dropped in EF migration) - Add existing-DB compatibility shim in MigrateAndConfigure (baselines InitialCreate migration for databases created by the old schema.sql) - Remove dead AddDbContext/AddScoped registrations from Worker (only IDbContextFactory is used by singleton consumers) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
59 lines
1.9 KiB
C#
59 lines
1.9 KiB
C#
using ClaudeDo.Data;
|
|
using ClaudeDo.Data.Git;
|
|
using ClaudeDo.Data.Repositories;
|
|
using ClaudeDo.Worker.Config;
|
|
using ClaudeDo.Worker.Hub;
|
|
using ClaudeDo.Worker.Runner;
|
|
using ClaudeDo.Worker.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
|
|
var cfg = WorkerConfig.Load();
|
|
|
|
var builder = WebApplication.CreateBuilder(args);
|
|
|
|
// When launched by the Windows SCM, speak the Service Control Protocol so SCM
|
|
// doesn't think we crashed (~30s timeout). No-op when running interactively.
|
|
builder.Host.UseWindowsService(o => o.ServiceName = "ClaudeDoWorker");
|
|
|
|
builder.Services.AddDbContextFactory<ClaudeDoDbContext>(opt =>
|
|
opt.UseSqlite($"Data Source={cfg.DbPath}"));
|
|
|
|
builder.Services.AddSingleton(cfg);
|
|
builder.Services.AddHostedService<StaleTaskRecovery>();
|
|
builder.Services.AddSignalR();
|
|
|
|
// Runner stack.
|
|
builder.Services.AddSingleton<IClaudeProcess, ClaudeProcess>();
|
|
builder.Services.AddSingleton<HubBroadcaster>();
|
|
builder.Services.AddSingleton<GitService>();
|
|
builder.Services.AddSingleton<WorktreeManager>();
|
|
builder.Services.AddSingleton<ClaudeArgsBuilder>();
|
|
builder.Services.AddSingleton<TaskRunner>();
|
|
|
|
// Agent file management.
|
|
var agentsDir = Path.Combine(ClaudeDo.Data.Paths.AppDataRoot(), "agents");
|
|
Directory.CreateDirectory(agentsDir);
|
|
builder.Services.AddSingleton(new AgentFileService(agentsDir));
|
|
|
|
// QueueService: singleton + hosted service (same instance).
|
|
builder.Services.AddSingleton<QueueService>();
|
|
builder.Services.AddHostedService(sp => sp.GetRequiredService<QueueService>());
|
|
|
|
// Loopback-only bind. Firewall is irrelevant for 127.0.0.1.
|
|
builder.WebHost.UseUrls($"http://127.0.0.1:{cfg.SignalRPort}");
|
|
|
|
var app = builder.Build();
|
|
|
|
using (var scope = app.Services.CreateScope())
|
|
{
|
|
ClaudeDoDbContext.MigrateAndConfigure(
|
|
scope.ServiceProvider.GetRequiredService<ClaudeDoDbContext>());
|
|
}
|
|
|
|
app.MapHub<WorkerHub>("/hub");
|
|
|
|
app.Logger.LogInformation("ClaudeDo.Worker listening on http://127.0.0.1:{Port} (db: {Db})",
|
|
cfg.SignalRPort, cfg.DbPath);
|
|
|
|
app.Run();
|