Browse Source

Commented out local configuration, to avoid exception

pull/974/head
Miguel Veloso 5 years ago
parent
commit
5c2b145ec2
3 changed files with 44 additions and 14 deletions
  1. +40
    -2
      src/Web/WebStatus/Program.cs
  2. +3
    -3
      src/Web/WebStatus/WebStatus.csproj
  3. +1
    -9
      src/Web/WebStatus/appsettings.json

+ 40
- 2
src/Web/WebStatus/Program.cs View File

@ -1,17 +1,19 @@
using Microsoft.AspNetCore; using Microsoft.AspNetCore;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration; using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Logging;
using Serilog; using Serilog;
using System; using System;
using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Reflection;
namespace WebStatus namespace WebStatus
{ {
public class Program public class Program
{ {
public static readonly string Namespace = typeof(Program).Namespace;
public static readonly string AppName = Namespace; public static readonly string AppName = Namespace;
public static readonly string Namespace = typeof(Program).Namespace;
public static int Main(string[] args) public static int Main(string[] args)
{ {
@ -24,6 +26,8 @@ namespace WebStatus
Log.Information("Configuring web host ({ApplicationContext})...", AppName); Log.Information("Configuring web host ({ApplicationContext})...", AppName);
var host = BuildWebHost(configuration, args); var host = BuildWebHost(configuration, args);
LogPackagesVersionInfo();
Log.Information("Starting web host ({ApplicationContext})...", AppName); Log.Information("Starting web host ({ApplicationContext})...", AppName);
host.Run(); host.Run();
@ -83,5 +87,39 @@ namespace WebStatus
return builder.Build(); return builder.Build();
} }
private static string GetVersion(Assembly assembly)
{
try
{
return $"{assembly.GetCustomAttribute<AssemblyFileVersionAttribute>()?.Version} ({assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion.Split()[0]})";
}
catch
{
return string.Empty;
}
}
private static void LogPackagesVersionInfo()
{
var assemblies = new List<Assembly>();
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);
}
} }
} }

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

@ -11,9 +11,9 @@
<None Remove="Views\**" /> <None Remove="Views\**" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.8" />
<PackageReference Include="AspNetCore.HealthChecks.UI" Version="2.2.19" />
<PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.2" /> <PackageReference Include="AspNetCore.HealthChecks.UI.Client" Version="2.2.2" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.0" />
<PackageReference Include="AspNetCore.HealthChecks.Uris" Version="2.2.2" />
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" /> <PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.2.1" />
<PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" /> <PackageReference Include="Microsoft.ApplicationInsights.DependencyCollector" Version="2.6.1" />
<PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.2" /> <PackageReference Include="Microsoft.ApplicationInsights.Kubernetes" Version="1.0.2" />
@ -24,7 +24,7 @@
<PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Logging.AzureAppServices" Version="2.2.0" />
<PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.172" /> <PackageReference Include="Microsoft.Web.LibraryManager.Build" Version="1.0.172" />
<PackageReference Include="Serilog.AspNetCore" Version="2.1.1" /> <PackageReference Include="Serilog.AspNetCore" Version="2.1.1" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.2" />
<PackageReference Include="Serilog.Enrichers.Environment" Version="2.1.3" />
<PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" /> <PackageReference Include="Serilog.Settings.Configuration" Version="3.0.1" />
<PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" /> <PackageReference Include="Serilog.Sinks.Console" Version="3.1.1" />
<PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" /> <PackageReference Include="Serilog.Sinks.Seq" Version="4.0.0" />


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

@ -1,5 +1,5 @@
{ {
"HealthChecks-UI": {
"HealthChecks-UI-commented-out": {
"HealthChecks": [ "HealthChecks": [
{ {
"Name": "Ordering HTTP Check", "Name": "Ordering HTTP Check",
@ -70,14 +70,6 @@
"Uri": "http://localhost:5121/hc" "Uri": "http://localhost:5121/hc"
} }
], ],
"Webhooks": [
{
"Name": "",
"Uri": "",
"Payload": "",
"RestoredPayload": ""
}
],
"EvaluationTimeOnSeconds": 10, "EvaluationTimeOnSeconds": 10,
"MinimumSecondsBetweenFailureNotifications": 60 "MinimumSecondsBetweenFailureNotifications": 60
}, },


Loading…
Cancel
Save