aboutsummaryrefslogtreecommitdiffstats
path: root/src/slskd/Program.cs
diff options
context:
space:
mode:
authorJP Dillingham <jp@dillingham.me>2026-01-30 18:15:12 -0600
committerGitHub <noreply@github.com>2026-01-30 18:15:12 -0600
commit09eabbce7d9bd4d42ffa9c30f97faa909a9ff8b0 (patch)
tree19e3a3da819dcd0568a10377fe8a6eacf3998902 /src/slskd/Program.cs
parent92b49b7a4035822240ba51ffdf3383eb9a30b164 (diff)
parentd2bf89cc204e89c04f66b778d9f94e325deb5a3d (diff)
downloadslskd-09eabbce7d9bd4d42ffa9c30f97faa909a9ff8b0.tar.gz
Merge pull request #1623 from slskd/runtime-config
Add the ability to apply an options 'overlay' at run-time; enabling update of listen IP and port
Diffstat (limited to 'src/slskd/Program.cs')
-rw-r--r--src/slskd/Program.cs15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/slskd/Program.cs b/src/slskd/Program.cs
index d6873dc0..75c51355 100644
--- a/src/slskd/Program.cs
+++ b/src/slskd/Program.cs
@@ -190,6 +190,11 @@ namespace slskd
public static string ConfigurationFile { get; private set; } = null;
/// <summary>
+ /// Gets the current configuration overlay, if one has been applied.
+ /// </summary>
+ public static OptionsOverlay ConfigurationOverlay => VolatileOverlayConfigurationSource?.CurrentValue;
+
+ /// <summary>
/// Gets the path where persistent data is saved.
/// </summary>
public static string DataDirectory { get; private set; } = null;
@@ -244,6 +249,7 @@ namespace slskd
private static ILogger Log { get; set; } = new ConsoleWriteLineLogger();
private static Mutex Mutex { get; set; }
private static IDisposable DotNetRuntimeStats { get; set; }
+ private static VolatileOverlayConfigurationSource<OptionsOverlay> VolatileOverlayConfigurationSource { get; set; } = new VolatileOverlayConfigurationSource<OptionsOverlay>();
[Argument('g', "generate-cert", "generate X509 certificate and password for HTTPs")]
private static bool GenerateCertificate { get; set; }
@@ -270,6 +276,12 @@ namespace slskd
public static void Exit(int code = 1) => Environment.Exit(code);
/// <summary>
+ /// Apply an instance of <see cref="OptionsOverlay"/> on top of the existing application configuration.
+ /// </summary>
+ /// <param name="overlay">The overlay containing the property values to be overlaid.</param>
+ public static void ApplyConfigurationOverlay(OptionsOverlay overlay) => VolatileOverlayConfigurationSource.Apply(overlay);
+
+ /// <summary>
/// Entrypoint.
/// </summary>
/// <param name="args">Command line arguments.</param>
@@ -1281,7 +1293,8 @@ namespace slskd
.AddCommandLine(
targetType: typeof(Options),
multiValuedArguments,
- commandLine: Environment.CommandLine);
+ commandLine: Environment.CommandLine)
+ .Add(VolatileOverlayConfigurationSource); // this must come last in order to supersede all other sources
}
private static IServiceCollection AddDbContext<T>(this IServiceCollection services, string connectionString)