From 5c2b145ec2463bd4f8cd3affa5b6dd6f40043b08 Mon Sep 17 00:00:00 2001 From: Miguel Veloso Date: Thu, 14 Mar 2019 16:50:44 +0000 Subject: [PATCH 1/2] Commented out local configuration, to avoid exception --- src/Web/WebStatus/Program.cs | 42 ++++++++++++++++++++++++++++-- src/Web/WebStatus/WebStatus.csproj | 6 ++--- src/Web/WebStatus/appsettings.json | 10 +------ 3 files changed, 44 insertions(+), 14 deletions(-) diff --git a/src/Web/WebStatus/Program.cs b/src/Web/WebStatus/Program.cs index d2de3ceae..91d004ae2 100644 --- a/src/Web/WebStatus/Program.cs +++ b/src/Web/WebStatus/Program.cs @@ -1,17 +1,19 @@ using Microsoft.AspNetCore; using Microsoft.AspNetCore.Hosting; using Microsoft.Extensions.Configuration; -using Microsoft.Extensions.Logging; using Serilog; using System; +using System.Collections.Generic; using System.IO; +using System.Linq; +using System.Reflection; namespace WebStatus { public class Program { - public static readonly string Namespace = typeof(Program).Namespace; public static readonly string AppName = Namespace; + public static readonly string Namespace = typeof(Program).Namespace; public static int Main(string[] args) { @@ -24,6 +26,8 @@ namespace WebStatus Log.Information("Configuring web host ({ApplicationContext})...", AppName); var host = BuildWebHost(configuration, args); + LogPackagesVersionInfo(); + Log.Information("Starting web host ({ApplicationContext})...", AppName); host.Run(); @@ -83,5 +87,39 @@ namespace WebStatus return builder.Build(); } + + private static string GetVersion(Assembly assembly) + { + try + { + return $"{assembly.GetCustomAttribute()?.Version} ({assembly.GetCustomAttribute()?.InformationalVersion.Split()[0]})"; + } + catch + { + return string.Empty; + } + } + + private static void LogPackagesVersionInfo() + { + var assemblies = new List(); + + foreach (var dependencyName in typeof(Program).Assembly.GetReferencedAssemblies()) + { + try + { + // Try to load the referenced assembly... + assemblies.Add(Assembly.Load(dependencyName)); + } + catch + { + // Failed to load assembly. Skip it. + } + } + + var versionList = assemblies.Select(a => $"-{a.GetName().Name} - {GetVersion(a)}").OrderBy(value => value); + + Log.Logger.ForContext("PackageVersions", string.Join("\n", versionList)).Information("Package versions ({ApplicationContext})", AppName); + } } } \ No newline at end of file diff --git a/src/Web/WebStatus/WebStatus.csproj b/src/Web/WebStatus/WebStatus.csproj index e898a3a2e..ea2cfb711 100644 --- a/src/Web/WebStatus/WebStatus.csproj +++ b/src/Web/WebStatus/WebStatus.csproj @@ -11,9 +11,9 @@ - + - + @@ -24,7 +24,7 @@ - + diff --git a/src/Web/WebStatus/appsettings.json b/src/Web/WebStatus/appsettings.json index 9ff359423..25b82f721 100644 --- a/src/Web/WebStatus/appsettings.json +++ b/src/Web/WebStatus/appsettings.json @@ -1,5 +1,5 @@ { - "HealthChecks-UI": { + "HealthChecks-UI-commented-out": { "HealthChecks": [ { "Name": "Ordering HTTP Check", @@ -70,14 +70,6 @@ "Uri": "http://localhost:5121/hc" } ], - "Webhooks": [ - { - "Name": "", - "Uri": "", - "Payload": "", - "RestoredPayload": "" - } - ], "EvaluationTimeOnSeconds": 10, "MinimumSecondsBetweenFailureNotifications": 60 }, From d5adb5f723544ae1423025d771153230ad0c6e91 Mon Sep 17 00:00:00 2001 From: Miguel Veloso Date: Mon, 18 Mar 2019 16:53:34 +0000 Subject: [PATCH 2/2] Update HealthChecks UI libraries to properly handle missing services. --- docker-compose.override.yml | 2 +- src/Web/WebStatus/Program.cs | 2 +- src/Web/WebStatus/WebStatus.csproj | 12 ++- .../WebStatus/appsettings.Development.json | 89 +++++++++++++++++-- src/Web/WebStatus/appsettings.json | 72 +-------------- 5 files changed, 96 insertions(+), 81 deletions(-) diff --git a/docker-compose.override.yml b/docker-compose.override.yml index 7353c744c..e59a9a2e6 100644 --- a/docker-compose.override.yml +++ b/docker-compose.override.yml @@ -324,7 +324,7 @@ services: webstatus: environment: - - ASPNETCORE_ENVIRONMENT=Development + - ASPNETCORE_ENVIRONMENT=Production - ASPNETCORE_URLS=http://0.0.0.0:80 - HealthChecks-UI__HealthChecks__1__Name=WebMVC HTTP Check - HealthChecks-UI__HealthChecks__1__Uri=http://webmvc/hc diff --git a/src/Web/WebStatus/Program.cs b/src/Web/WebStatus/Program.cs index 91d004ae2..d97ca289f 100644 --- a/src/Web/WebStatus/Program.cs +++ b/src/Web/WebStatus/Program.cs @@ -12,8 +12,8 @@ namespace WebStatus { public class Program { - public static readonly string AppName = Namespace; public static readonly string Namespace = typeof(Program).Namespace; + public static readonly string AppName = Namespace; public static int Main(string[] args) { diff --git a/src/Web/WebStatus/WebStatus.csproj b/src/Web/WebStatus/WebStatus.csproj index ea2cfb711..320780ffa 100644 --- a/src/Web/WebStatus/WebStatus.csproj +++ b/src/Web/WebStatus/WebStatus.csproj @@ -11,8 +11,8 @@ - - + + @@ -29,5 +29,13 @@ + + + Always + + + Always + + diff --git a/src/Web/WebStatus/appsettings.Development.json b/src/Web/WebStatus/appsettings.Development.json index fa8ce71a9..39aa0f472 100644 --- a/src/Web/WebStatus/appsettings.Development.json +++ b/src/Web/WebStatus/appsettings.Development.json @@ -1,10 +1,87 @@ { - "Logging": { - "IncludeScopes": false, - "LogLevel": { - "Default": "Debug", - "System": "Information", - "Microsoft": "Information" + "HealthChecks-UI": { + "HealthChecks": [ + { + "Name": "Ordering HTTP Check", + "Uri": "http://localhost:5102/hc" + }, + { + "Name": "Ordering HTTP Background Check", + "Uri": "http://localhost:5111/hc" + }, + { + "Name": "Basket HTTP Check", + "Uri": "http://localhost:5103/hc" + }, + { + "Name": "Catalog HTTP Check", + "Uri": "http://localhost:5101/hc" + }, + { + "Name": "Identity HTTP Check", + "Uri": "http://localhost:5105/hc" + }, + { + "Name": "Marketing HTTP Check", + "Uri": "http://localhost:5110/hc" + }, + { + "Name": "Locations HTTP Check", + "Uri": "http://localhost:5109/hc" + }, + { + "Name": "Payments HTTP Check", + "Uri": "http://localhost:5108/hc" + }, + { + "Name": "WebMVC HTTP Check", + "Uri": "http://localhost:5100/hc" + }, + { + "Name": "WebSPA HTTP Check", + "Uri": "http://localhost:5104/hc" + }, + { + "Name": "SignalR HTTP Check", + "Uri": "http://localhost:5112/hc" + }, + { + "Name": "Mobile Shopping API GW HTTP Check", + "Uri": "http://localhost:5200/hc" + }, + { + "Name": "Mobile Marketing API GW HTTP Check", + "Uri": "http://localhost:5201/hc" + }, + { + "Name": "Web Shopping API GW HTTP Check", + "Uri": "http://localhost:5202/hc" + }, + { + "Name": "Web Marketing API GW HTTP Check", + "Uri": "http://localhost:5203/hc" + }, + { + "Name": "Mobile Shopping Aggregator HTTP Check", + "Uri": "http://localhost:5120/hc" + }, + { + "Name": "Web Shopping Aggregator HTTP Check", + "Uri": "http://localhost:5121/hc" + } + ], + "EvaluationTimeOnSeconds": 10, + "MinimumSecondsBetweenFailureNotifications": 60 + }, + "Serilog": { + "SeqServerUrl": "http://localhost:5341/", + "MinimumLevel": { + "Default": "Information", + "Override": { + "Microsoft": "Warning", + "Microsoft.eShopOnContainers": "Information", + "System": "Warning" + } } } } diff --git a/src/Web/WebStatus/appsettings.json b/src/Web/WebStatus/appsettings.json index 25b82f721..d5589cc5a 100644 --- a/src/Web/WebStatus/appsettings.json +++ b/src/Web/WebStatus/appsettings.json @@ -1,75 +1,5 @@ { - "HealthChecks-UI-commented-out": { - "HealthChecks": [ - { - "Name": "Ordering HTTP Check", - "Uri": "http://localhost:5102/hc" - }, - { - "Name": "Ordering HTTP Background Check", - "Uri": "http://localhost:5111/hc" - }, - { - "Name": "Basket HTTP Check", - "Uri": "http://localhost:5103/hc" - }, - { - "Name": "Catalog HTTP Check", - "Uri": "http://localhost:5101/hc" - }, - { - "Name": "Identity HTTP Check", - "Uri": "http://localhost:5105/hc" - }, - { - "Name": "Marketing HTTP Check", - "Uri": "http://localhost:5110/hc" - }, - { - "Name": "Locations HTTP Check", - "Uri": "http://localhost:5109/hc" - }, - { - "Name": "Payments HTTP Check", - "Uri": "http://localhost:5108/hc" - }, - { - "Name": "WebMVC HTTP Check", - "Uri": "http://localhost:5100/hc" - }, - { - "Name": "WebSPA HTTP Check", - "Uri": "http://localhost:5104/hc" - }, - { - "Name": "SignalR HTTP Check", - "Uri": "http://localhost:5112/hc" - }, - { - "Name": "Mobile Shopping API GW HTTP Check", - "Uri": "http://localhost:5200/hc" - }, - { - "Name": "Mobile Marketing API GW HTTP Check", - "Uri": "http://localhost:5201/hc" - }, - { - "Name": "Web Shopping API GW HTTP Check", - "Uri": "http://localhost:5202/hc" - }, - { - "Name": "Web Marketing API GW HTTP Check", - "Uri": "http://localhost:5203/hc" - }, - { - "Name": "Mobile Shopping Aggregator HTTP Check", - "Uri": "http://localhost:5120/hc" - }, - { - "Name": "Web Shopping Aggregator HTTP Check", - "Uri": "http://localhost:5121/hc" - } - ], + "HealthChecks-UI": { "EvaluationTimeOnSeconds": 10, "MinimumSecondsBetweenFailureNotifications": 60 },