Made small tweak to startup

This commit is contained in:
David Fowler 2023-05-04 16:23:24 -07:00 committed by Reuben Bond
parent 0fd20ee962
commit 5397e8d5c8
3 changed files with 35 additions and 34 deletions

View File

@ -16,31 +16,21 @@ builder.Services.AddTransient<IIdentityService, IdentityService>();
var app = builder.Build();
try
if (!await app.CheckHealthAsync())
{
if (!await app.CheckHealthAsync())
{
return 1;
}
app.UseServiceDefaults();
app.MapGet("/", () => Results.Redirect("/swagger"));
app.MapGrpcService<BasketService>();
app.MapControllers();
var eventBus = app.Services.GetRequiredService<IEventBus>();
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
eventBus.Subscribe<OrderStartedIntegrationEvent, OrderStartedIntegrationEventHandler>();
await app.RunAsync();
return 0;
}
catch (Exception ex)
{
app.Logger.LogCritical(ex, "Program terminated unexpectedly");
return 1;
return;
}
app.UseServiceDefaults();
app.MapGet("/", () => Results.Redirect("/swagger"));
app.MapGrpcService<BasketService>();
app.MapControllers();
var eventBus = app.Services.GetRequiredService<IEventBus>();
eventBus.Subscribe<ProductPriceChangedIntegrationEvent, ProductPriceChangedIntegrationEventHandler>();
eventBus.Subscribe<OrderStartedIntegrationEvent, OrderStartedIntegrationEventHandler>();
await app.RunAsync();

View File

@ -7,7 +7,7 @@ builder.AddServiceDefaults();
builder.Services.AddGrpc();
builder.Services.AddControllers();
// Applcation specific services
// Application specific services
builder.Services.AddDbContexts(builder.Configuration);
builder.Services.AddApplicationOptions(builder.Configuration);
builder.Services.AddHealthChecks(builder.Configuration);
@ -18,6 +18,11 @@ builder.Services.AddTransient<OrderStatusChangedToPaidIntegrationEventHandler>()
var app = builder.Build();
if (!await app.CheckHealthAsync())
{
return;
}
app.UseServiceDefaults();
app.UseFileServer(new FileServerOptions

View File

@ -1,9 +1,9 @@
{
"UseCustomizationData": false,
"AzureServiceBusEnabled": false,
"AzureStorageEnabled": false,
"ApplicationInsights": {
"InstrumentationKey": ""
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"OpenApi": {
"Endpoint": {
@ -22,6 +22,12 @@
"EventBus": {
"SubscriptionClientName": "Catalog",
"RetryCount": 5
}
},
"ApplicationInsights": {
"InstrumentationKey": ""
},
"UseCustomizationData": false,
"AzureServiceBusEnabled": false,
"AzureStorageEnabled": false
}