Files
MoShiro/backend/src/MoShiro.Backend.Application/ApplicationServiceCollectionExtensions.cs
T
justme 636a784043
ci/woodpecker/push/main-amd64-build Pipeline is running
fix: the panel polls the registry for its own and the nodes' releases [CI]
Registering a manifest with the panel is best effort in CI (an unreachable
panel only warns, the pipeline stays green). The Backend update notice then
never appeared, because the host updater only reads the mailbox the panel
writes. A background poller now fetches the signed manifests of the agent, the
probe and the backend itself from the registry every five minutes, verifies the
release signature and registers them, writing the backend one into the host
updater's mailbox.
2026-10-08 19:09:21 +08:00

78 lines
3.6 KiB
C#

using Fleet.Server;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
namespace MoShiro.Backend.Application;
public static class ApplicationServiceCollectionExtensions
{
/// <summary>
/// 注册 Application 层的全部服务。需要事先注册端口的实现(存储、<see cref="IAgentGateway"/>)和 <see cref="TimeProvider"/>。
/// 后台任务按这里的顺序启动:<see cref="StartupTasks"/> 必须在最前面。
/// </summary>
public static IServiceCollection AddMoShiroApplication(this IServiceCollection services, BackendOptions options)
{
services.AddSingleton(options);
services.AddHostedService<StartupTasks>();
services.AddSingleton<AgentRuntime>();
services.AddSingleton<LiveHub>();
services.AddSingleton<HotLayer>();
services.AddSingleton<BackendCounters>();
services.AddSingleton<RawQueryGate>();
services.AddSingleton<LoginRateLimiter>();
services.AddSingleton<TaskPlanner>();
services.AddSingleton<TaskService>();
services.AddSingleton<AgentService>();
services.AddSingleton<AgentEventService>();
services.AddSingleton<HostStatusService>();
services.AddSingleton<NodeInfoService>();
services.AddSingleton<ProbeService>();
services.AddSingleton<LinkService>();
services.AddSingleton<LineService>();
services.AddSingleton<TestService>();
services.AddSingleton<IngestService>();
services.AddSingleton<WindowComputer>();
services.AddSingleton<AuthService>();
services.AddSingleton<PasskeyService>();
services.AddSingleton<AuditService>();
services.AddSingleton<ServerIdentityService>();
services.AddSingleton<SetupService>();
services.AddSingleton<ReleaseFeed>();
services.AddSingleton<ReleaseKeyService>();
services.AddSingleton<NodeOwnerService>();
services.AddSingleton<Fleet.Server.IServerIdentity>(sp => sp.GetRequiredService<ServerIdentityService>());
services.AddSingleton<TrustService>();
services.AddSingleton<Fleet.Server.IOperatorTrustSource>(sp => sp.GetRequiredService<TrustService>());
services.AddSingleton<SettingsService>();
services.AddSingleton<ReleaseService>();
services.AddSingleton<ScheduleService>();
services.AddSingleton<BackendUpdates>();
services.AddHostedService(p => p.GetRequiredService<BackendUpdates>());
services.AddSingleton<JoinTokenService>();
services.AddSingleton<RawBrowserService>();
services.AddSingleton<EventService>();
services.AddSingleton<OpsService>();
services.AddSingleton<RangeResolver>();
services.AddSingleton<SourcePlanner>();
services.AddSingleton<RowLoader>();
services.AddSingleton<QueryService>();
services.AddSingleton<IEnrollmentHook, MoShiroEnrollmentHook>();
services.AddSingleton<INodeEventSink, MoShiroNodeEventSink>();
services.AddSingleton<AnalysisScheduler>();
services.AddHostedService(provider => provider.GetRequiredService<AnalysisScheduler>());
services.AddSingleton<MetricRecompute>();
services.AddHostedService(provider => provider.GetRequiredService<MetricRecompute>());
services.AddSingleton<TestFinalizer>();
services.AddHostedService(provider => provider.GetRequiredService<TestFinalizer>());
services.AddHostedService<HotLayerBackfill>();
services.AddHostedService<RetentionService>();
services.AddHostedService<ReleasePoller>();
return services;
}
}