Browse Source

Added MVC and SPA Apps to healthChecker

Added styles to view
pull/144/head
Ramón Tomás 7 years ago
parent
commit
e08fe895a3
18 changed files with 134 additions and 19 deletions
  1. +2
    -0
      docker-compose.override.yml
  2. +1
    -1
      src/Services/Catalog/Catalog.API/Startup.cs
  3. +6
    -0
      src/Services/Identity/Identity.API/Identity.API.csproj
  4. +1
    -0
      src/Services/Identity/Identity.API/Program.cs
  5. +8
    -1
      src/Services/Identity/Identity.API/Startup.cs
  6. +1
    -1
      src/Services/Identity/Identity.API/appsettings.json
  7. +1
    -0
      src/Web/WebMVC/Program.cs
  8. +7
    -1
      src/Web/WebMVC/Startup.cs
  9. +6
    -0
      src/Web/WebMVC/WebMVC.csproj
  10. +6
    -0
      src/Web/WebSPA/Startup.cs
  11. +6
    -0
      src/Web/WebSPA/WebSPA.csproj
  12. +1
    -0
      src/Web/WebSPA/appsettings.json
  13. +2
    -1
      src/Web/WebStatus/Startup.cs
  14. +31
    -8
      src/Web/WebStatus/Views/Home/Index.cshtml
  15. +4
    -4
      src/Web/WebStatus/Views/Shared/_Layout.cshtml
  16. +1
    -1
      src/Web/WebStatus/WebStatus.csproj
  17. +2
    -1
      src/Web/WebStatus/appsettings.json
  18. +48
    -0
      src/Web/WebStatus/wwwroot/css/site.css

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

@ -86,5 +86,7 @@ services:
- OrderingUrl=http://ordering.api:5102/hc
- BasketUrl=http://basket.api:5103/hc
- IdentityUrl=http://10.0.75.1:5105/hc
- mvc=http://webmvc:5100/hc
- spa=http://webspa:5104/hc
ports:
- "5107:5107"

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

@ -40,7 +40,7 @@
services.AddHealthChecks(checks =>
{
checks.AddUrlCheck(Configuration["ConnectionString"]);
checks.AddUrlCheck(Configuration["ExternalCatalogBaseUrl"]);
});
services.AddDbContext<CatalogContext>(c =>


+ 6
- 0
src/Services/Identity/Identity.API/Identity.API.csproj View File

@ -57,6 +57,12 @@
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.Data\Microsoft.Extensions.HealthChecks.Data.csproj" />
<ProjectReference Include="..\..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Dockerfile">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>


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

@ -9,6 +9,7 @@ namespace eShopOnContainers.Identity
{
var host = new WebHostBuilder()
.UseKestrel()
.UseHealthChecks("/hc")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()


+ 8
- 1
src/Services/Identity/Identity.API/Startup.cs View File

@ -17,6 +17,7 @@ using IdentityServer4.Services;
using System.Threading;
using Microsoft.eShopOnContainers.Services.Catalog.API.Infrastructure;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.HealthChecks;
namespace eShopOnContainers.Identity
{
@ -43,7 +44,8 @@ namespace eShopOnContainers.Identity
// This method gets called by the runtime. Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
{
// Add framework services.
services.AddDbContext<ApplicationDbContext>(options =>
options.UseSqlServer(Configuration.GetConnectionString("DefaultConnection")));
@ -56,6 +58,11 @@ namespace eShopOnContainers.Identity
services.AddMvc();
services.AddHealthChecks(checks =>
{
checks.AddSqlCheck("Identity_Db", Configuration.GetConnectionString("DefaultConnection"));
});
services.AddTransient<IEmailSender, AuthMessageSender>();
services.AddTransient<ISmsSender, AuthMessageSender>();
services.AddTransient<ILoginService<ApplicationUser>, EFLoginService>();


+ 1
- 1
src/Services/Identity/Identity.API/appsettings.json View File

@ -1,6 +1,6 @@
{
"ConnectionStrings": {
"DefaultConnection": "Server=127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word"
"DefaultConnection": "Server=tcp:127.0.0.1,5433;Database=Microsoft.eShopOnContainers.Services.IdentityDb;User Id=sa;Password=Pass@word;"
},
"MvcClient": "http://localhost:5100",
"SpaClient": "http://localhost:5104",


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

@ -9,6 +9,7 @@ namespace Microsoft.eShopOnContainers.WebMVC
{
var host = new WebHostBuilder()
.UseKestrel()
.UseHealthChecks("/hc")
.UseContentRoot(Directory.GetCurrentDirectory())
.UseIISIntegration()
.UseStartup<Startup>()


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

@ -15,6 +15,7 @@ using Microsoft.AspNetCore.Http;
using System.Threading;
using Microsoft.Extensions.Options;
using WebMVC.Services.Utilities;
using Microsoft.Extensions.HealthChecks;
namespace Microsoft.eShopOnContainers.WebMVC
{
@ -44,7 +45,12 @@ namespace Microsoft.eShopOnContainers.WebMVC
{
services.AddMvc();
services.Configure<AppSettings>(Configuration);
services.AddHealthChecks(checks =>
{
checks.AddUrlCheck(Configuration["CallBackUrl"]);
});
// Add application services.
services.AddSingleton<IHttpContextAccessor, HttpContextAccessor>();
services.AddTransient<ICatalogService, CatalogService>();


+ 6
- 0
src/Web/WebMVC/WebMVC.csproj View File

@ -51,6 +51,12 @@
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.Data\Microsoft.Extensions.HealthChecks.Data.csproj" />
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Dockerfile">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>


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

@ -9,6 +9,7 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json.Serialization;
using eShopOnContainers.WebSPA;
using Microsoft.Extensions.HealthChecks;
namespace eShopConContainers.WebSPA
{
@ -39,6 +40,11 @@ namespace eShopConContainers.WebSPA
// For more information on how to configure your application, visit http://go.microsoft.com/fwlink/?LinkID=398940
public void ConfigureServices(IServiceCollection services)
{
services.AddHealthChecks(checks =>
{
checks.AddUrlCheck(Configuration["CallBackUrl"]);
});
services.Configure<AppSettings>(Configuration);
services.AddAntiforgery(options => options.HeaderName = "X-XSRF-TOKEN");


+ 6
- 0
src/Web/WebSPA/WebSPA.csproj View File

@ -78,6 +78,12 @@
<DotNetCliToolReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Tools" Version="1.0.0-msbuild3-final" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.AspNetCore.HealthChecks\Microsoft.AspNetCore.HealthChecks.csproj" />
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks.Data\Microsoft.Extensions.HealthChecks.Data.csproj" />
<ProjectReference Include="..\..\BuildingBlocks\HealthChecks\src\Microsoft.Extensions.HealthChecks\Microsoft.Extensions.HealthChecks.csproj" />
</ItemGroup>
<ItemGroup>
<None Update="Dockerfile">
<CopyToOutputDirectory>Always</CopyToOutputDirectory>


+ 1
- 0
src/Web/WebSPA/appsettings.json View File

@ -3,6 +3,7 @@
"OrderingUrl": "http://localhost:5102",
"BasketUrl": "http://localhost:5103",
"IdentityUrl": "http://localhost:5105",
"CallBackUrl": "http://localhost:5104/",
"Logging": {
"IncludeScopes": false,
"LogLevel": {


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

@ -35,8 +35,9 @@ namespace WebStatus
checks.AddUrlCheckIfNotNull(Configuration["OrderingUrl"]);
checks.AddUrlCheckIfNotNull(Configuration["BasketUrl"]);
checks.AddUrlCheckIfNotNull(Configuration["CatalogUrl"]);
checks.AddUrlCheckIfNotNull(Configuration["IdentityUrl"]);
checks.AddUrlCheckIfNotNull(Configuration["mvc"]);
checks.AddUrlCheckIfNotNull(Configuration["spa"]);
checks.AddUrlCheckIfNotNull(Configuration["spa"]);
});
services.AddMvc();
}


+ 31
- 8
src/Web/WebStatus/Views/Home/Index.cshtml View File

@ -7,14 +7,37 @@
<div class="row">
<div class="col-md-12">
<h2>Overall Status: @Model.OverallStatus</h2>
<h2 class="overall-status-title">Overall Status: @Model.OverallStatus</h2>
</div>
</div>
@foreach (var result in Model.Results)
{
<div class="row">
<div class="col-md-6">@result.Description</div>
<div class="col-md-6">@result.CheckStatus</div>
</div>
}
<div class="list-group-status">
@foreach (var result in Model.Results)
{
<div class="row list-group-status-item">
<div class="col-md-10">
<h4 class="list-group-status-item-title">@result.Data["url"]</h4>
<p class="list-group-item-text">@result.Description</p>
</div>
<div class="col-md-2 list-group-status-item-label">
@if (@result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Healthy)
{
<span class="label label-success">@result.CheckStatus</span>
}
else if (@result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Unhealthy)
{
<span class="label label-danger">@result.CheckStatus</span>
}
else if (@result.CheckStatus == Microsoft.Extensions.HealthChecks.CheckStatus.Warning)
{
<span class="label label-warning">@result.CheckStatus</span>
}
else
{
<span class="label label-default">@result.CheckStatus</span>
}
</div>
</div>
}
</div>

+ 4
- 4
src/Web/WebStatus/Views/Shared/_Layout.cshtml View File

@ -41,11 +41,11 @@
</nav>
<div class="container body-content">
@RenderBody()
<hr />
<footer>
<p>&copy; 2017 - WebStatus</p>
</footer>
</div>
<footer class="container footer">
<p class="center">&copy; 2017 - WebStatus</p>
</footer>
<environment names="Development">
<script src="~/lib/jquery/dist/jquery.js"></script>


+ 1
- 1
src/Web/WebStatus/WebStatus.csproj View File

@ -1,10 +1,10 @@
<Project Sdk="Microsoft.NET.Sdk.Web">
<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
</PropertyGroup>
<PropertyGroup>
<RuntimeFrameworkVersion>1.1.0</RuntimeFrameworkVersion>
<PackageTargetFallback>$(PackageTargetFallback);portable-net45+win8+wp8+wpa81;</PackageTargetFallback>
<DockerComposeProjectPath>..\..\..\docker-compose.dcproj</DockerComposeProjectPath>
</PropertyGroup>


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

@ -7,5 +7,6 @@
},
"OrderingUrl": "http://localhost:5102/hc",
"BasketUrl": "http://localhost:5103/hc",
"CatalogUrl": "http://localhost:5101/hc"
"CatalogUrl": "http://localhost:5101/hc",
"IdentityUrl": "http://localhost:5105/hc"
}

+ 48
- 0
src/Web/WebStatus/wwwroot/css/site.css View File

@ -35,3 +35,51 @@ textarea {
display: none;
}
}
.overall-status-title {
font-weight: 700;
margin-top: 20px;
margin-bottom: 15px;
}
.list-group-status {
max-width: 70%;
}
.list-group-status-item {
position: relative;
display: block;
padding: 10px 15px;
margin-bottom: -1px;
background-color: #fff;
border: 1px solid #ddd;
}
.list-group-status-item:first-child {
border-top-left-radius: 8px;
border-top-right-radius: 8px;
}
.list-group-status-item:last-child {
margin-bottom: 0;
border-bottom-right-radius: 8px;
border-bottom-left-radius: 8px;
}
.list-group-status-item-title {
color: dodgerblue;
font-weight: 700;
}
.list-group-status-item-label {
margin-top: 10px;
font-size: 24px;
}
.footer {
position: absolute;
bottom: 0;
width: 100%;
height: 60px;
background-color: #f5f5f5;
}

Loading…
Cancel
Save