Browse Source

Made small tweak to startup

davidfowl/common-services
David Fowler 1 year ago
committed by Reuben Bond
parent
commit
5397e8d5c8
3 changed files with 30 additions and 29 deletions
  1. +11
    -21
      src/Services/Basket/Basket.API/Program.cs
  2. +6
    -1
      src/Services/Catalog/Catalog.API/Program.cs
  3. +13
    -7
      src/Services/Catalog/Catalog.API/appsettings.json

+ 11
- 21
src/Services/Basket/Basket.API/Program.cs View File

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

+ 6
- 1
src/Services/Catalog/Catalog.API/Program.cs View File

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


+ 13
- 7
src/Services/Catalog/Catalog.API/appsettings.json View File

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

Loading…
Cancel
Save