From 9e5487494ed766a3922ab5621abf4cedf8a69aee Mon Sep 17 00:00:00 2001 From: Jordan Dominion Date: Thu, 24 Aug 2023 19:46:40 -0400 Subject: [PATCH] Fix configuration "reloading" during setup wizard It runs again after setup so it's completely unnecessary. --- src/Tgstation.Server.Host/ServerFactory.cs | 6 +++++- .../Setup/SetupWizard.cs | 20 +------------------ 2 files changed, 6 insertions(+), 20 deletions(-) diff --git a/src/Tgstation.Server.Host/ServerFactory.cs b/src/Tgstation.Server.Host/ServerFactory.cs index 0256395b7d..2dd323022d 100644 --- a/src/Tgstation.Server.Host/ServerFactory.cs +++ b/src/Tgstation.Server.Host/ServerFactory.cs @@ -24,6 +24,11 @@ namespace Tgstation.Server.Host /// sealed class ServerFactory : IServerFactory { + /// + /// Name of the appsettings file. + /// + public const string AppSettings = "appsettings"; + /// /// The for the . /// @@ -60,7 +65,6 @@ namespace Tgstation.Server.Host args[oldArgs.Length] = "--hostBuilder:reloadConfigOnChange=false"; } - const string AppSettings = "appsettings"; const string AppSettingsRelocationKey = $"--{AppSettings}-base-path="; var appsettingsRelativeBasePathArgument = args.FirstOrDefault(arg => arg.StartsWith(AppSettingsRelocationKey, StringComparison.Ordinal)); diff --git a/src/Tgstation.Server.Host/Setup/SetupWizard.cs b/src/Tgstation.Server.Host/Setup/SetupWizard.cs index 3ea5f694f6..92b3d53c42 100644 --- a/src/Tgstation.Server.Host/Setup/SetupWizard.cs +++ b/src/Tgstation.Server.Host/Setup/SetupWizard.cs @@ -87,11 +87,6 @@ namespace Tgstation.Server.Host.Setup /// readonly InternalConfiguration internalConfiguration; - /// - /// A that will complete when the is reloaded. - /// - TaskCompletionSource reloadTcs; - /// /// Initializes a new instance of the class. /// @@ -131,12 +126,6 @@ namespace Tgstation.Server.Host.Setup generalConfiguration = generalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(generalConfigurationOptions)); internalConfiguration = internalConfigurationOptions?.Value ?? throw new ArgumentNullException(nameof(internalConfigurationOptions)); - - configuration - .GetReloadToken() - .RegisterChangeCallback( - state => reloadTcs?.TrySetResult(), - null); } /// @@ -1014,19 +1003,12 @@ namespace Tgstation.Server.Host.Setup var configBytes = Encoding.UTF8.GetBytes(serializedYaml); - reloadTcs = new TaskCompletionSource(); - try { await ioManager.WriteAllBytes( userConfigFileName, configBytes, cancellationToken); - - // Ensure the reload - if (generalConfiguration.SetupWizardMode != SetupWizardMode.Only) - using (cancellationToken.Register(() => reloadTcs.TrySetCanceled())) - await reloadTcs.Task; } catch (OperationCanceledException) { @@ -1108,7 +1090,7 @@ namespace Tgstation.Server.Host.Setup var userConfigFileName = ioManager.ConcatPath( internalConfiguration.AppSettingsBasePath, - String.Format(CultureInfo.InvariantCulture, "appsettings.{0}.yml", hostingEnvironment.EnvironmentName)); + $"{ServerFactory.AppSettings}.{hostingEnvironment.EnvironmentName}.yml"); async Task HandleSetupCancel() {