Browse Source

Add Healthchecks to Locations.API and MArketing.API

pull/235/head
dsanz 7 years ago
parent
commit
a65e9c01eb
11 changed files with 30 additions and 2 deletions
  1. +3
    -0
      docker-compose.override.yml
  2. +2
    -0
      src/Services/Location/Locations.API/Locations.API.csproj
  3. +1
    -0
      src/Services/Location/Locations.API/Program.cs
  4. +7
    -0
      src/Services/Location/Locations.API/Startup.cs
  5. +2
    -0
      src/Services/Marketing/Marketing.API/Marketing.API.csproj
  6. +1
    -0
      src/Services/Marketing/Marketing.API/Program.cs
  7. +6
    -0
      src/Services/Marketing/Marketing.API/Startup.cs
  8. +1
    -0
      src/Web/WebMVC/Startup.cs
  9. +1
    -0
      src/Web/WebSPA/Startup.cs
  10. +3
    -1
      src/Web/WebStatus/Startup.cs
  11. +3
    -1
      src/Web/WebStatus/appsettings.json

+ 3
- 0
docker-compose.override.yml View File

@ -82,6 +82,7 @@ services:
- 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.
- BasketUrlHC=http://basket.api/hc
- MarketingUrlHC=http://marketing.api/hc
- UseCustomizationData=True
ports:
- "5104:80"
@ -119,6 +120,8 @@ services:
- OrderingUrl=http://ordering.api/hc
- BasketUrl=http://basket.api/hc
- IdentityUrl=http://identity.api/hc
- LocationsUrl=http://locations.api/hc
- MarketingUrl=http://marketing.api/hc
- mvc=http://webmvc/hc
- spa=http://webspa/hc
ports:


+ 2
- 0
src/Services/Location/Locations.API/Locations.API.csproj View File

@ -41,6 +41,8 @@
<ItemGroup>
<ProjectReference Include="..\..\..\BuildingBlocks\EventBus\EventBusRabbitMQ\EventBusRabbitMQ.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>
</Project>

+ 1
- 0
src/Services/Location/Locations.API/Program.cs View File

@ -14,6 +14,7 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
{
var host = new WebHostBuilder()
.UseKestrel()
.UseHealthChecks("/hc")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseApplicationInsights()


+ 7
- 0
src/Services/Location/Locations.API/Startup.cs View File

@ -16,6 +16,8 @@ using Microsoft.Extensions.Logging;
using RabbitMQ.Client;
using System.Reflection;
using System;
using Microsoft.Extensions.HealthChecks;
using System.Threading.Tasks;
namespace Microsoft.eShopOnContainers.Services.Locations.API
{
@ -51,6 +53,11 @@ namespace Microsoft.eShopOnContainers.Services.Locations.API
services.Configure<LocationSettings>(Configuration);
services.AddHealthChecks(checks =>
{
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
});
services.AddSingleton<IRabbitMQPersistentConnection>(sp =>
{
var logger = sp.GetRequiredService<ILogger<DefaultRabbitMQPersistentConnection>>();


+ 2
- 0
src/Services/Marketing/Marketing.API/Marketing.API.csproj View File

@ -56,6 +56,8 @@
</ItemGroup>
<ItemGroup>
<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>


+ 1
- 0
src/Services/Marketing/Marketing.API/Program.cs View File

@ -10,6 +10,7 @@
{
var host = new WebHostBuilder()
.UseKestrel()
.UseHealthChecks("/hc")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseStartup<Startup>()
.UseWebRoot("Pics")


+ 6
- 0
src/Services/Marketing/Marketing.API/Startup.cs View File

@ -26,6 +26,7 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API
using Polly;
using System.Threading.Tasks;
using System.Data.SqlClient;
using Microsoft.Extensions.HealthChecks;
public class Startup
{
@ -60,6 +61,11 @@ namespace Microsoft.eShopOnContainers.Services.Marketing.API
services.Configure<MarketingSettings>(Configuration);
services.AddHealthChecks(checks =>
{
checks.AddValueTaskCheck("HTTP Endpoint", () => new ValueTask<IHealthCheckResult>(HealthCheckResult.Healthy("Ok")));
});
services.AddDbContext<MarketingContext>(options =>
{
options.UseSqlServer(Configuration["ConnectionString"],


+ 1
- 0
src/Web/WebMVC/Startup.cs View File

@ -64,6 +64,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
checks.AddUrlCheck(Configuration["OrderingUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
checks.AddUrlCheck(Configuration["BasketUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
checks.AddUrlCheck(Configuration["IdentityUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
checks.AddUrlCheck(Configuration["MarketingUrl"] + "/hc", TimeSpan.FromMinutes(minutes));
});
// Add application services.


+ 1
- 0
src/Web/WebSPA/Startup.cs View File

@ -57,6 +57,7 @@ namespace eShopConContainers.WebSPA
checks.AddUrlCheck(Configuration["OrderingUrlHC"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheck(Configuration["BasketUrlHC"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheck(Configuration["IdentityUrlHC"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheck(Configuration["MarketingUrlHC"], TimeSpan.FromMinutes(minutes));
});
services.Configure<AppSettings>(Configuration);


+ 3
- 1
src/Web/WebStatus/Startup.cs View File

@ -42,8 +42,10 @@ namespace WebStatus
checks.AddUrlCheckIfNotNull(Configuration["BasketUrl"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["CatalogUrl"], 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["spa"], TimeSpan.FromMinutes(minutes));
checks.AddUrlCheckIfNotNull(Configuration["spa"], TimeSpan.FromMinutes(minutes));
});
services.AddMvc();
}


+ 3
- 1
src/Web/WebStatus/appsettings.json View File

@ -8,5 +8,7 @@
"OrderingUrl": "http://localhost:5102/hc",
"BasketUrl": "http://localhost:5103/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…
Cancel
Save