From 0c6eb67f3b5795215a18bf07de818dbc9217e071 Mon Sep 17 00:00:00 2001 From: Joe DeCock Date: Tue, 7 Jan 2025 11:38:31 -0600 Subject: [PATCH 1/2] fix(is): LicenseUsageSummary resolution Fixed usage in the main host of the LicenseUsageSummary so that it is resolved at shutdown properly. --- hosts/main/Program.cs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/hosts/main/Program.cs b/hosts/main/Program.cs index cee27845f..27ca14d6b 100644 --- a/hosts/main/Program.cs +++ b/hosts/main/Program.cs @@ -38,12 +38,14 @@ try .ConfigureServices() .ConfigurePipeline(); - var usage = app.Services.GetRequiredService(); + app.Lifetime.ApplicationStopping.Register(() => + { + var usage = app.Services.GetRequiredService(); + Console.Write(Summary(usage)); + Console.ReadKey(); + }); app.Run(); - - Console.Write(Summary(usage)); - Console.ReadKey(); } catch (Exception ex) { @@ -55,7 +57,7 @@ finally Log.CloseAndFlush(); } -string Summary(LicenseUsageSummary usage) +static string Summary(LicenseUsageSummary usage) { var sb = new StringBuilder(); sb.AppendLine("IdentityServer Usage Summary:"); @@ -67,4 +69,3 @@ string Summary(LicenseUsageSummary usage) return sb.ToString(); } - \ No newline at end of file From 0d95d547bda3f3015fd8a55d644ea9e3a0780409 Mon Sep 17 00:00:00 2001 From: Joe DeCock Date: Tue, 7 Jan 2025 14:23:59 -0600 Subject: [PATCH 2/2] fix(is): Only summarize usage in dev --- hosts/main/Program.cs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/hosts/main/Program.cs b/hosts/main/Program.cs index 27ca14d6b..dc8d2b51b 100644 --- a/hosts/main/Program.cs +++ b/hosts/main/Program.cs @@ -38,12 +38,17 @@ try .ConfigureServices() .ConfigurePipeline(); - app.Lifetime.ApplicationStopping.Register(() => + if (app.Environment.IsDevelopment()) { - var usage = app.Services.GetRequiredService(); - Console.Write(Summary(usage)); - Console.ReadKey(); - }); + app.Lifetime.ApplicationStopping.Register(() => + { + var usage = app.Services.GetRequiredService(); + Console.Write(Summary(usage)); + { + Console.ReadKey(); + } + }); + } app.Run(); }