diff options
| author | JP Dillingham <jpdillingham@gmail.com> | 2021-11-13 16:40:10 -0600 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-11-13 16:40:10 -0600 |
| commit | 2aebad636b3ad89090e9f563e79ff8194cf5f78d (patch) | |
| tree | 0d3adb39846ba65f9dfdfffd51d8f6c065d150f6 | |
| parent | d12b421a66becff8fa757bce363a9e874275c9c2 (diff) | |
| parent | 27c43ffa6c33520fa65e6fce48f8637ce69c7948 (diff) | |
| download | slskd-2aebad636b3ad89090e9f563e79ff8194cf5f78d.tar.gz | |
Merge branch 'master' into user-info-picture
| -rw-r--r-- | config/slskd.example.yml | 1 | ||||
| -rw-r--r-- | src/slskd/Core/API/Controllers/ApplicationController.cs | 15 | ||||
| -rw-r--r-- | src/slskd/Options.cs | 9 | ||||
| -rw-r--r-- | src/slskd/Startup.cs | 5 | ||||
| -rw-r--r-- | src/slskd/slskd.csproj | 4 |
5 files changed, 31 insertions, 3 deletions
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/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); } + + /// <summary> + /// Forces garbage collection. + /// </summary> + /// <returns></returns> + [HttpPost("gc")] + [Authorize] + public async Task<IActionResult> CollectGarbage() + { + GCSettings.LargeObjectHeapCompactionMode = GCLargeObjectHeapCompactionMode.CompactOnce; + GC.Collect(2, GCCollectionMode.Forced, blocking: false, compacting: true); + + return Ok(); + } } } 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 @@ -692,6 +692,15 @@ namespace slskd public string ContentPath { get; private set; } = "wwwroot"; /// <summary> + /// Gets a value indicating whether HTTP request logging should be enabled. + /// </summary> + [Argument(default, "http-logging")] + [EnvironmentVariable("HTTP_LOGGING")] + [Description("enable http request logging")] + [RequiresRestart] + public bool Logging { get; private set; } = false; + + /// <summary> /// Gets authentication options. /// </summary> [Validate] 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(); 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 @@ <PackageReference Include="Serilog.Sinks.File" Version="5.0.0" /> <PackageReference Include="Serilog.Sinks.Grafana.Loki" Version="7.1.0" /> <PackageReference Include="Serilog.Sinks.Http" Version="7.2.0" /> - <PackageReference Include="SonarAnalyzer.CSharp" Version="8.30.0.37606"> + <PackageReference Include="SonarAnalyzer.CSharp" Version="8.31.0.39249"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> </PackageReference> - <PackageReference Include="Soulseek" Version="3.0.0-pre-1102210644" /> + <PackageReference Include="Soulseek" Version="3.0.0-pre-991113210753" /> <PackageReference Include="StyleCop.Analyzers" Version="1.2.0-beta.354"> <PrivateAssets>all</PrivateAssets> <IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets> |
