From c1ea20c31218220d325826f0d2b121651309c2fe Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 13 Nov 2021 13:00:08 -0600 Subject: bump dependencies, add route to force garbage collection --- src/slskd/Core/API/Controllers/ApplicationController.cs | 15 +++++++++++++++ src/slskd/slskd.csproj | 4 ++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/slskd/Core/API/Controllers/ApplicationController.cs b/src/slskd/Core/API/Controllers/ApplicationController.cs index 16cd68b9..a7168efb 100644 --- a/src/slskd/Core/API/Controllers/ApplicationController.cs +++ b/src/slskd/Core/API/Controllers/ApplicationController.cs @@ -19,6 +19,7 @@ namespace slskd.Core.API { using System; using System.Diagnostics; + using System.Runtime; using System.Threading.Tasks; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; @@ -111,5 +112,19 @@ namespace slskd.Core.API return Ok(ApplicationStateMonitor.CurrentValue.Version); } + + /// + /// Forces garbage collection. + /// + /// + [HttpPost("gc")] + [Authorize] + public async Task CollectGarbage() + { + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; + GC.Collect(2, GCCollectionMode.Forced, blocking: false, compacting: true); + + return Ok(); + } } } diff --git a/src/slskd/slskd.csproj b/src/slskd/slskd.csproj index 124238e4..58f7cfe0 100644 --- a/src/slskd/slskd.csproj +++ b/src/slskd/slskd.csproj @@ -64,11 +64,11 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + all runtime; build; native; contentfiles; analyzers; buildtransitive -- cgit v1.2.3 From 7439e0ef4db92941455af3e4f5b4e3736a51d6dc Mon Sep 17 00:00:00 2001 From: JP Dillingham Date: Sat, 13 Nov 2021 15:00:05 -0600 Subject: add option to suppress HTTP logging --- config/slskd.example.yml | 1 + src/slskd/Options.cs | 9 +++++++++ src/slskd/Startup.cs | 5 ++++- 3 files changed, 14 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/config/slskd.example.yml b/config/slskd.example.yml index 643911e2..ce424595 100644 --- a/config/slskd.example.yml +++ b/config/slskd.example.yml @@ -25,6 +25,7 @@ # password: ~ # url_base: / # content_path: wwwroot +# logging: false # authentication: # disable: false # username: slskd diff --git a/src/slskd/Options.cs b/src/slskd/Options.cs index 71c341e9..0d487cc2 100644 --- a/src/slskd/Options.cs +++ b/src/slskd/Options.cs @@ -691,6 +691,15 @@ namespace slskd [RequiresRestart] public string ContentPath { get; private set; } = "wwwroot"; + /// + /// Gets a value indicating whether HTTP request logging should be enabled. + /// + [Argument(default, "http-logging")] + [EnvironmentVariable("HTTP_LOGGING")] + [Description("enable http request logging")] + [RequiresRestart] + public bool Logging { get; private set; } = false; + /// /// Gets authentication options. /// diff --git a/src/slskd/Startup.cs b/src/slskd/Startup.cs index 98deac0d..a8b64305 100644 --- a/src/slskd/Startup.cs +++ b/src/slskd/Startup.cs @@ -324,7 +324,10 @@ namespace slskd logger.Information("Publishing Prometheus metrics to /metrics"); } - app.UseSerilogRequestLogging(); + if (OptionsAtStartup.Web.Logging) + { + app.UseSerilogRequestLogging(); + } app.UseAuthentication(); -- cgit v1.2.3