-
Notifications
You must be signed in to change notification settings - Fork 49
Expand file tree
/
Copy pathRunCommand.cs
More file actions
37 lines (32 loc) · 1.55 KB
/
RunCommand.cs
File metadata and controls
37 lines (32 loc) · 1.55 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
namespace ServiceControl.Audit.Infrastructure.Hosting.Commands
{
using System.Threading.Tasks;
using Microsoft.AspNetCore.Builder;
using NServiceBus;
using ServiceControl.Hosting.Auth;
using ServiceControl.Hosting.Https;
using Settings;
using WebApi;
class RunCommand : AbstractCommand
{
public override async Task Execute(HostArguments args, Settings settings)
{
var endpointConfiguration = new EndpointConfiguration(settings.InstanceName);
var assemblyScanner = endpointConfiguration.AssemblyScanner();
assemblyScanner.ExcludeAssemblies("ServiceControl.Plugin");
var hostBuilder = WebApplication.CreateBuilder();
hostBuilder.AddServiceControlAuthentication(settings.OpenIdConnectSettings);
hostBuilder.AddServiceControlHttps(settings.HttpsSettings);
hostBuilder.AddServiceControlAudit((_, __) =>
{
//Do nothing. The transports in NSB 8 are designed to handle broker outages. Audit ingestion will be paused when broker is unavailable.
return Task.CompletedTask;
}, settings, endpointConfiguration);
hostBuilder.AddServiceControlAuditApi(settings);
var app = hostBuilder.Build();
app.UseServiceControlAudit(settings.ForwardedHeadersSettings, settings.HttpsSettings, settings.EnableMcpServer);
app.UseServiceControlAuthentication(settings.OpenIdConnectSettings.Enabled);
await app.RunAsync(settings.RootUrl);
}
}
}