Add Healthchecks to Locations.API and MArketing.API
This commit is contained in:
parent
e9b4235543
commit
a65e9c01eb
@ -82,6 +82,7 @@ services:
|
|||||||
- OrderingUrlHC=http://ordering.api/hc
|
- OrderingUrlHC=http://ordering.api/hc
|
||||||
- IdentityUrlHC=http://identity.api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser.
|
- IdentityUrlHC=http://identity.api/hc #Local: Use ${ESHOP_PROD_EXTERNAL_DNS_NAME_OR_IP}, if using external IP or DNS name from browser.
|
||||||
- BasketUrlHC=http://basket.api/hc
|
- BasketUrlHC=http://basket.api/hc
|
||||||
|
- MarketingUrlHC=http://marketing.api/hc
|
||||||
- UseCustomizationData=True
|
- UseCustomizationData=True
|
||||||
ports:
|
ports:
|
||||||
- "5104:80"
|
- "5104:80"
|
||||||
@ -119,6 +120,8 @@ services:
|
|||||||
- OrderingUrl=http://ordering.api/hc
|
- OrderingUrl=http://ordering.api/hc
|
||||||
- BasketUrl=http://basket.api/hc
|
- BasketUrl=http://basket.api/hc
|
||||||
- IdentityUrl=http://identity.api/hc
|
- IdentityUrl=http://identity.api/hc
|
||||||
|
- LocationsUrl=http://locations.api/hc
|
||||||
|
- MarketingUrl=http://marketing.api/hc
|
||||||
- mvc=http://webmvc/hc
|
- mvc=http://webmvc/hc
|
||||||
- spa=http://webspa/hc
|
- spa=http://webspa/hc
|
||||||
ports:
|
ports:
|
||||||
|
@ -41,6 +41,8 @@
|
|||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBus\EventBus.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
@ -14,6 +14,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
|
|||||||
{
|
{
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
.UseKestrel()
|
.UseKestrel()
|
||||||
|
.UseHealthChecks("/hc")
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
.UseApplicationInsights()
|
.UseApplicationInsights()
|
||||||
|
@ -16,6 +16,8 @@ using Microsoft.Extensions.Logging;
|
|||||||
using RabbitMQ.Client;
|
using RabbitMQ.Client;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
using System;
|
using System;
|
||||||
|
using Microsoft.Extensions.HealthChecks;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Microsoft.eShopOnContainers.Services.Locations.API
|
namespace Microsoft.eShopOnContainers.Services.Locations.API
|
||||||
{
|
{
|
||||||
@ -51,6 +53,11 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
|
|||||||
|
|
||||||
services.Configure<LocationSettings>(Configuration);
|
services.Configure<LocationSettings>(Configuration);
|
||||||
|
|
||||||
|
services.AddHealthChecks(checks =>
|
||||||
|
{
|
||||||
|
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
|
||||||
|
});
|
||||||
|
|
||||||
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
|
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
|
||||||
{
|
{
|
||||||
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
|
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();
|
||||||
|
@ -56,6 +56,8 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
|
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
|
||||||
|
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
@ -10,6 +10,7 @@
|
|||||||
{
|
{
|
||||||
var host = new WebHostBuilder()
|
var host = new WebHostBuilder()
|
||||||
.UseKestrel()
|
.UseKestrel()
|
||||||
|
.UseHealthChecks("/hc")
|
||||||
.UseContentRoot(Directory.GetCurrentDirectory())
|
.UseContentRoot(Directory.GetCurrentDirectory())
|
||||||
.UseStartup<Startup>()
|
.UseStartup<Startup>()
|
||||||
.UseWebRoot("Pics")
|
.UseWebRoot("Pics")
|
||||||
|
@ -26,6 +26,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API
|
|||||||
using Polly;
|
using Polly;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
|
using Microsoft.Extensions.HealthChecks;
|
||||||
|
|
||||||
public class Startup
|
public class Startup
|
||||||
{
|
{
|
||||||
@ -60,6 +61,11 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API
|
|||||||
|
|
||||||
services.Configure<MarketingSettings>(Configuration);
|
services.Configure<MarketingSettings>(Configuration);
|
||||||
|
|
||||||
|
services.AddHealthChecks(checks =>
|
||||||
|
{
|
||||||
|
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
|
||||||
|
});
|
||||||
|
|
||||||
services.AddDbContext<MarketingContext>(options =>
|
services.AddDbContext<MarketingContext>(options =>
|
||||||
{
|
{
|
||||||
options.UseSqlServer(Configuration["ConnectionString"],
|
options.UseSqlServer(Configuration["ConnectionString"],
|
||||||
|
@ -64,6 +64,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
|
|||||||
checks.AddUrlCheck(Configuration["OrderingUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheck(Configuration["OrderingUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
|
||||||
checks.AddUrlCheck(Configuration["BasketUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheck(Configuration["BasketUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
|
||||||
checks.AddUrlCheck(Configuration["IdentityUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheck(Configuration["IdentityUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheck(Configuration["MarketingUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Add application services.
|
// Add application services.
|
||||||
|
@ -57,6 +57,7 @@ namespace eShopConContainers.WebSPA
|
|||||||
checks.AddUrlCheck(Configuration["OrderingUrlHC"], TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheck(Configuration["OrderingUrlHC"], TimeSpan.FromMinutes(minutes));
|
||||||
checks.AddUrlCheck(Configuration["BasketUrlHC"], TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheck(Configuration["BasketUrlHC"], TimeSpan.FromMinutes(minutes));
|
||||||
checks.AddUrlCheck(Configuration["IdentityUrlHC"], TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheck(Configuration["IdentityUrlHC"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheck(Configuration["MarketingUrlHC"], TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
|
|
||||||
services.Configure<AppSettings>(Configuration);
|
services.Configure<AppSettings>(Configuration);
|
||||||
|
@ -42,8 +42,10 @@ namespace WebStatus
|
|||||||
checks.AddUrlCheckIfNotNull(Configuration["BasketUrl"], TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheckIfNotNull(Configuration["BasketUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["CatalogUrl"], TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheckIfNotNull(Configuration["CatalogUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["IdentityUrl"], TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheckIfNotNull(Configuration["IdentityUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheckIfNotNull(Configuration["LocationsUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
|
checks.AddUrlCheckIfNotNull(Configuration["MarketingUrl"], TimeSpan.FromMinutes(minutes));
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["mvc"], TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheckIfNotNull(Configuration["mvc"], TimeSpan.FromMinutes(minutes));
|
||||||
checks.AddUrlCheckIfNotNull(Configuration["spa"], TimeSpan.FromMinutes(minutes));
|
checks.AddUrlCheckIfNotNull(Configuration["spa"], TimeSpan.FromMinutes(minutes));
|
||||||
});
|
});
|
||||||
services.AddMvc();
|
services.AddMvc();
|
||||||
}
|
}
|
||||||
|
@ -8,5 +8,7 @@
|
|||||||
"OrderingUrl": "http://localhost:5102/hc",
|
"OrderingUrl": "http://localhost:5102/hc",
|
||||||
"BasketUrl": "http://localhost:5103/hc",
|
"BasketUrl": "http://localhost:5103/hc",
|
||||||
"CatalogUrl": "http://localhost:5101/hc",
|
"CatalogUrl": "http://localhost:5101/hc",
|
||||||
"IdentityUrl": "http://localhost:5105/hc"
|
"IdentityUrl": "http://localhost:5105/hc",
|
||||||
|
"MarketingUrl": "http://localhost:5110/hc",
|
||||||
|
"LocationsUrl": "http://localhost:5109/hc"
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user