aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config/slskd.example.yml1
-rw-r--r--src/slskd/Core/Options.cs9
-rw-r--r--src/slskd/Program.cs8
3 files changed, 14 insertions, 4 deletions
diff --git a/config/slskd.example.yml b/config/slskd.example.yml
index b1f4ce08..8a4ed133 100644
--- a/config/slskd.example.yml
+++ b/config/slskd.example.yml
@@ -5,6 +5,7 @@
# flags:
# no_logo: false
# no_start: false
+# no_config_watch: false
# no_connect: false
# no_share_scan: false
# force_share_scan: false
diff --git a/src/slskd/Core/Options.cs b/src/slskd/Core/Options.cs
index c1f4d558..3727b89d 100644
--- a/src/slskd/Core/Options.cs
+++ b/src/slskd/Core/Options.cs
@@ -333,6 +333,15 @@ namespace slskd
public bool NoStart { get; init; } = false;
/// <summary>
+ /// Gets a value indicating whether the application should watch the configuration file for changes.
+ /// </summary>
+ [Argument(default, "no-config-watch")]
+ [EnvironmentVariable("NO_CONFIG_WATCH")]
+ [Description("do not watch the config file for changes")]
+ [RequiresRestart]
+ public bool NoConfigWatch { get; init; } = false;
+
+ /// <summary>
/// Gets a value indicating whether the application should connect to the Soulseek network on startup.
/// </summary>
[Argument(default, "no-connect")]
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index 03cc6c75..8aa1e102 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -350,7 +350,7 @@ namespace slskd
try
{
Configuration = new ConfigurationBuilder()
- .AddConfigurationProviders(EnvironmentVariablePrefix, ConfigurationFile)
+ .AddConfigurationProviders(EnvironmentVariablePrefix, ConfigurationFile, reloadOnChange: !OptionsAtStartup.Flags.NoConfigWatch)
.Build();
Configuration.GetSection(AppName)
@@ -436,7 +436,7 @@ namespace slskd
var builder = WebApplication.CreateBuilder(args);
builder.Configuration
- .AddConfigurationProviders(EnvironmentVariablePrefix, ConfigurationFile);
+ .AddConfigurationProviders(EnvironmentVariablePrefix, ConfigurationFile, reloadOnChange: !OptionsAtStartup.Flags.NoConfigWatch);
builder.Host
.UseSerilog();
@@ -1019,7 +1019,7 @@ namespace slskd
.CreateLogger();
}
- private static IConfigurationBuilder AddConfigurationProviders(this IConfigurationBuilder builder, string environmentVariablePrefix, string configurationFile)
+ private static IConfigurationBuilder AddConfigurationProviders(this IConfigurationBuilder builder, string environmentVariablePrefix, string configurationFile, bool reloadOnChange)
{
configurationFile = Path.GetFullPath(configurationFile);
@@ -1045,7 +1045,7 @@ namespace slskd
path: Path.GetFileName(configurationFile),
targetType: typeof(Options),
optional: true,
- reloadOnChange: true,
+ reloadOnChange: reloadOnChange,
provider: new PhysicalFileProvider(Path.GetDirectoryName(configurationFile), ExclusionFilters.None)) // required for locations outside of the app directory
.AddCommandLine(
targetType: typeof(Options),