-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
51 lines (41 loc) · 1.78 KB
/
Copy pathProgram.cs
File metadata and controls
51 lines (41 loc) · 1.78 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
using EventStore.Client;
using EventStoreMonitor.Configuration;
using EventStoreMonitor.Services;
var host = Host.CreateApplicationBuilder(args);
var config = host.Configuration;
host.Services
.AddOptions<EventStoreOptions>()
.Bind(config.GetSection(EventStoreOptions.SectionName))
.ValidateDataAnnotations()
.ValidateOnStart();
host.Services
.AddOptions<EmailOptions>()
.Bind(config.GetSection(EmailOptions.SectionName))
.ValidateDataAnnotations()
.ValidateOnStart();
host.Services.AddSingleton(sp =>
{
var opts = sp.GetRequiredService<IConfiguration>()
.GetSection(EventStoreOptions.SectionName)
.Get<EventStoreOptions>()
?? throw new InvalidOperationException("EventStore configuration is missing.");
var settings = EventStoreClientSettings.Create(opts.ConnectionString);
return new EventStoreClient(settings);
});
host.Services.AddSingleton<EmailNotificationService>();
host.Services.AddSingleton<CheckpointService>();
host.Services.AddHostedService<CrashNotificationService>();
host.Services.AddHostedService<MonitorOrchestratorService>();
AppDomain.CurrentDomain.UnhandledException += (_, e) =>
{
Console.Error.WriteLine($"[FATAL] Unhandled exception: {e.ExceptionObject}");
};
var app = host.Build();
Console.WriteLine("""
╔═══════════════════════════════════════════════════╗
║ EventStore Monitor — Personal Alerts ║
║ Read-only catch-up subscriptions. No side effects║
╚═══════════════════════════════════════════════════╝
Press Ctrl+C to stop.
""");
await app.RunAsync();