Fix configuration "reloading" during setup wizard

It runs again after setup so it's completely unnecessary.
This commit is contained in:
Jordan Dominion
2023-08-24 19:46:40 -04:00
parent 63815c950f
commit 9e5487494e
2 changed files with 6 additions and 20 deletions
+5 -1
View File
@@ -24,6 +24,11 @@ namespace Tgstation.Server.Host
/// </summary>
sealed class ServerFactory : IServerFactory
{
/// <summary>
/// Name of the appsettings file.
/// </summary>
public const string AppSettings = "appsettings";
/// <summary>
/// The <see cref="IAssemblyInformationProvider"/> for the <see cref="ServerFactory"/>.
/// </summary>
@@ -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));
+1 -19
View File
@@ -87,11 +87,6 @@ namespace Tgstation.Server.Host.Setup
/// </summary>
readonly InternalConfiguration internalConfiguration;
/// <summary>
/// A <see cref="TaskCompletionSource"/> that will complete when the <see cref="IConfiguration"/> is reloaded.
/// </summary>
TaskCompletionSource reloadTcs;
/// <summary>
/// Initializes a new instance of the <see cref="SetupWizard"/> class.
/// </summary>
@@ -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);
}
/// <inheritdoc />
@@ -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()
{