Explicitly disable config reloading

Closes #1143
This commit is contained in:
Jordan Dominion
2023-06-22 18:12:35 -04:00
parent 75c5c92911
commit 6681bd3ecb
2 changed files with 14 additions and 11 deletions
@@ -17,7 +17,6 @@ using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.Extensions.Primitives;
using Newtonsoft.Json;
@@ -421,14 +420,6 @@ namespace Tgstation.Server.Host.Core
logger.LogDebug("Content Root: {contentRoot}", hostingEnvironment.ContentRootPath);
logger.LogTrace("Web Root: {webRoot}", hostingEnvironment.WebRootPath);
// attempt to restart the server if the configuration changes
if (serverControl.WatchdogPresent)
ChangeToken.OnChange(Configuration.GetReloadToken, () =>
{
logger.LogInformation("Configuration change detected");
serverControl.Restart();
});
// setup the HTTP request pipeline
// Add additional logging context to the request
applicationBuilder.UseAdditionalRequestLoggingContext(swarmConfiguration);
+14 -2
View File
@@ -1,4 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
@@ -48,14 +50,24 @@ namespace Tgstation.Server.Host
{
ArgumentNullException.ThrowIfNull(args);
// need to shove this arg in to disable config reloading unless a user specifically overrides it
if (!args.Any(arg => arg.Contains("hostBuilder:reloadConfigOnChange", StringComparison.OrdinalIgnoreCase))
&& String.IsNullOrWhiteSpace(Environment.GetEnvironmentVariable("hostBuilder__reloadConfigOnChange")))
{
var oldArgs = args;
args = new string[oldArgs.Length + 1];
Array.Copy(oldArgs, args, oldArgs.Length);
args[oldArgs.Length] = "--hostBuilder:reloadConfigOnChange=false";
}
var basePath = IOManager.ResolvePath();
IHostBuilder CreateDefaultBuilder() => Microsoft.Extensions.Hosting.Host.CreateDefaultBuilder(args)
.ConfigureAppConfiguration((context, builder) =>
{
builder.SetBasePath(basePath);
builder.AddYamlFile("appsettings.yml", optional: true, reloadOnChange: true)
.AddYamlFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.yml", optional: true, reloadOnChange: true);
builder.AddYamlFile("appsettings.yml", optional: true, reloadOnChange: false)
.AddYamlFile($"appsettings.{context.HostingEnvironment.EnvironmentName}.yml", optional: true, reloadOnChange: false);
// reorganize the builder so our yaml configs don't override the env/cmdline configs
// values obtained via debugger