From 62c9f1cc36b457e9558255ba968fd68db15de113 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 02:05:33 +0000 Subject: [PATCH 1/7] adding optional load of appsettings.json in SPACEFX_CONFIG_DIR --- src/Client.cs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Client.cs b/src/Client.cs index de72107..992636a 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -127,6 +127,10 @@ public Client() { var builder = WebApplication.CreateBuilder(); builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false); + if(! string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR")) && Directory.Exists(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"))) { + builder.Configuration.AddJsonFile(Path.Combine(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"), "appsettings.json"), optional: true, reloadOnChange: false); + } + builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => { services.AddAzureOrbitalFramework(); From d36229d968c8363cce5e0ec385b12eea8a5e7240 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 02:36:47 +0000 Subject: [PATCH 2/7] updating to config subdirectory --- src/Client.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Client.cs b/src/Client.cs index 992636a..c764833 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -128,7 +128,7 @@ public Client() { builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false); if(! string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR")) && Directory.Exists(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"))) { - builder.Configuration.AddJsonFile(Path.Combine(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"), "appsettings.json"), optional: true, reloadOnChange: false); + builder.Configuration.AddJsonFile(Path.Combine(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"), "config", "appsettings.json"), optional: true, reloadOnChange: false); } builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) From 91304c07d2214e36c20e363d7b64642c5c67648b Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 02:39:01 +0000 Subject: [PATCH 3/7] removing duplicate environment variable setting --- src/Client.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Client.cs b/src/Client.cs index c764833..1f752d0 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -120,10 +120,6 @@ public static Task DirectToApp(string appId, IMessage message) { public Client() { if (_grpcHost != null || _client != null) return; - - Environment.SetEnvironmentVariable("DOTNET_HOSTBUILDER__RELOADCONFIGONCHANGE", "false"); - Environment.SetEnvironmentVariable("DOTNET_USE_POLLING_FILE_WATCHER", "true"); - Environment.SetEnvironmentVariable("DOTNET_SYSTEM_GLOBALIZATION_INVARIANT", "1"); var builder = WebApplication.CreateBuilder(); builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false); From 7288e70842c56c1a6d548c190428fd5a59536653 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 02:40:55 +0000 Subject: [PATCH 4/7] adjusting order of appsettings load --- src/Client.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/Client.cs b/src/Client.cs index 1f752d0..632b950 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -121,11 +121,14 @@ public Client() { if (_grpcHost != null || _client != null) return; var builder = WebApplication.CreateBuilder(); + // Load the configuration being supplicated by the cluster first + builder.Configuration.AddJsonFile(Path.Combine(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"), "config", "appsettings.json"), optional: true, reloadOnChange: false); + + // Load any local appsettings incase they're overriding the cluster values builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false); - if(! string.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR")) && Directory.Exists(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"))) { - builder.Configuration.AddJsonFile(Path.Combine(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"), "config", "appsettings.json"), optional: true, reloadOnChange: false); - } + + builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => { From 42599e6e3f8a17df24ca6b4d0c2315b3559921a3 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 02:46:57 +0000 Subject: [PATCH 5/7] adding dotnet environment file --- src/Client.cs | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Client.cs b/src/Client.cs index 632b950..60bcd63 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -122,11 +122,14 @@ public Client() { var builder = WebApplication.CreateBuilder(); // Load the configuration being supplicated by the cluster first - builder.Configuration.AddJsonFile(Path.Combine(Environment.GetEnvironmentVariable("SPACEFX_CONFIG_DIR"), "config", "appsettings.json"), optional: true, reloadOnChange: false); + builder.Configuration.AddJsonFile(Path.Combine("{env:SPACEFX_CONFIG_DIR}", "config", "appsettings.json"), optional: true, reloadOnChange: false); // Load any local appsettings incase they're overriding the cluster values builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.json"), optional: true, reloadOnChange: false); + // Load any local appsettings incase they're overriding the cluster values + builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); + From 1032bff75063255c74f1eae2910855a0688610b5 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 02:55:12 +0000 Subject: [PATCH 6/7] adding build method --- src/Client.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Client.cs b/src/Client.cs index 60bcd63..f267fe9 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -130,7 +130,8 @@ public Client() { // Load any local appsettings incase they're overriding the cluster values builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); - + // Build the configuration + build.Configuration.Build(); builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) From 1d56d0e7ef375b189f4257f9b533fb4d5dd79a95 Mon Sep 17 00:00:00 2001 From: Ryan Campbell Date: Fri, 2 Aug 2024 03:07:08 +0000 Subject: [PATCH 7/7] copy paste dust bunny --- src/Client.cs | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/Client.cs b/src/Client.cs index f267fe9..e6787cd 100644 --- a/src/Client.cs +++ b/src/Client.cs @@ -130,10 +130,6 @@ public Client() { // Load any local appsettings incase they're overriding the cluster values builder.Configuration.AddJsonFile(Path.Combine(Directory.GetCurrentDirectory(), "appsettings.{env:DOTNET_ENVIRONMENT}.json"), optional: true, reloadOnChange: false); - // Build the configuration - build.Configuration.Build(); - - builder.WebHost.ConfigureKestrel(options => options.ListenAnyIP(50051, o => o.Protocols = HttpProtocols.Http2)) .ConfigureServices((services) => { services.AddAzureOrbitalFramework();