From 15077e97abbddcea1ab68a5368ed168bc8ab1df6 Mon Sep 17 00:00:00 2001 From: Sebastian Date: Fri, 27 May 2022 13:31:30 +0200 Subject: [PATCH] Unify config. --- Dockerfile | 5 ++--- .../Diagnostics/Diagnoser.cs | 6 +++--- .../Diagnostics/DiagnoserOptions.cs | 4 ++-- .../Diagnostics/GCHealthCheck.cs | 2 +- .../Diagnostics/GCHealthCheckOptions.cs | 2 +- .../Squidex/Config/Domain/HealthCheckServices.cs | 2 +- backend/src/Squidex/appsettings.json | 16 +++++++--------- 7 files changed, 17 insertions(+), 20 deletions(-) diff --git a/Dockerfile b/Dockerfile index 78c42dcd5..b89020746 100644 --- a/Dockerfile +++ b/Dockerfile @@ -83,13 +83,12 @@ COPY --from=backend /tools . # Default app directory WORKDIR /app -# Copy backend files +# Copy from build stages COPY --from=backend /build/ . - -# Copy frontend files to backend folder. COPY --from=frontend /build/ wwwroot/build/ EXPOSE 80 +EXPOSE 443 EXPOSE 11111 ENV DIAGNOSTICS__COUNTERSTOOL=/tools/dotnet-counters diff --git a/backend/src/Squidex.Infrastructure/Diagnostics/Diagnoser.cs b/backend/src/Squidex.Infrastructure/Diagnostics/Diagnoser.cs index 12dc17e23..36eb45f59 100644 --- a/backend/src/Squidex.Infrastructure/Diagnostics/Diagnoser.cs +++ b/backend/src/Squidex.Infrastructure/Diagnostics/Diagnoser.cs @@ -32,7 +32,7 @@ namespace Squidex.Infrastructure.Diagnostics public Task InitializeAsync( CancellationToken ct) { - if (options.DumpTrigger > 0 || options.GCDumpTrigger > 0) + if (options.DumpTriggerInMB > 0 || options.GCDumpTriggerInMB > 0) { timer = new Timer(CollectDump); timer.Change(TimeSpan.Zero, TimeSpan.FromSeconds(5)); @@ -70,12 +70,12 @@ namespace Squidex.Infrastructure.Diagnostics { var workingSet = Process.GetCurrentProcess().WorkingSet64 / (1024 * 1024); - if (options.DumpTrigger > 0 && workingSet > options.DumpTrigger && scheduledDumpTask == null) + if (options.DumpTriggerInMB > 0 && workingSet > options.DumpTriggerInMB && scheduledDumpTask == null) { scheduledDumpTask = CreateDumpAsync(); } - if (options.GCDumpTrigger > 0 && workingSet > options.GCDumpTrigger && scheduledGcDumpTask == null) + if (options.GCDumpTriggerInMB > 0 && workingSet > options.GCDumpTriggerInMB && scheduledGcDumpTask == null) { scheduledGcDumpTask = CreateGCDumpAsync(); } diff --git a/backend/src/Squidex.Infrastructure/Diagnostics/DiagnoserOptions.cs b/backend/src/Squidex.Infrastructure/Diagnostics/DiagnoserOptions.cs index 425f5c867..5104e7362 100644 --- a/backend/src/Squidex.Infrastructure/Diagnostics/DiagnoserOptions.cs +++ b/backend/src/Squidex.Infrastructure/Diagnostics/DiagnoserOptions.cs @@ -13,8 +13,8 @@ namespace Squidex.Infrastructure.Diagnostics public string? DumpTool { get; set; } - public int GCDumpTrigger { get; set; } + public int GCDumpTriggerInMB { get; set; } - public int DumpTrigger { get; set; } + public int DumpTriggerInMB { get; set; } } } diff --git a/backend/src/Squidex.Infrastructure/Diagnostics/GCHealthCheck.cs b/backend/src/Squidex.Infrastructure/Diagnostics/GCHealthCheck.cs index 512c00653..7077b8de7 100644 --- a/backend/src/Squidex.Infrastructure/Diagnostics/GCHealthCheck.cs +++ b/backend/src/Squidex.Infrastructure/Diagnostics/GCHealthCheck.cs @@ -17,7 +17,7 @@ namespace Squidex.Infrastructure.Diagnostics public GCHealthCheck(IOptions options) { - threshold = 1024 * 1024 * options.Value.Threshold; + threshold = 1024 * 1024 * options.Value.ThresholdInMB; } public Task CheckHealthAsync(HealthCheckContext context, diff --git a/backend/src/Squidex.Infrastructure/Diagnostics/GCHealthCheckOptions.cs b/backend/src/Squidex.Infrastructure/Diagnostics/GCHealthCheckOptions.cs index 3532eb589..63434d1c1 100644 --- a/backend/src/Squidex.Infrastructure/Diagnostics/GCHealthCheckOptions.cs +++ b/backend/src/Squidex.Infrastructure/Diagnostics/GCHealthCheckOptions.cs @@ -9,6 +9,6 @@ namespace Squidex.Infrastructure.Diagnostics { public sealed class GCHealthCheckOptions { - public long Threshold { get; set; } = 4 * 1024L; + public long ThresholdInMB { get; set; } = 8192; } } diff --git a/backend/src/Squidex/Config/Domain/HealthCheckServices.cs b/backend/src/Squidex/Config/Domain/HealthCheckServices.cs index 3b6ad4969..1797d90b4 100644 --- a/backend/src/Squidex/Config/Domain/HealthCheckServices.cs +++ b/backend/src/Squidex/Config/Domain/HealthCheckServices.cs @@ -16,7 +16,7 @@ namespace Squidex.Config.Domain public static void AddSquidexHealthChecks(this IServiceCollection services, IConfiguration config) { services.Configure(config, - "healthz:gc"); + "diagnostics:gc"); services.AddHealthChecks() .AddCheck("GC", tags: new[] { "node" }) diff --git a/backend/src/Squidex/appsettings.json b/backend/src/Squidex/appsettings.json index 6c43c64d9..d8ef16e80 100644 --- a/backend/src/Squidex/appsettings.json +++ b/backend/src/Squidex/appsettings.json @@ -204,13 +204,6 @@ "text": "User-agent: *\nAllow: /api/assets/*" }, - "healthz": { - "gc": { - // The maximum number of megabyte that the process can consume until it is marked as not healthy. - "threshold": 4096 - } - }, - "apps": { // True to delete apps permanently. // @@ -326,7 +319,7 @@ "dumpTool": "", // When more memory is allocated that the defined value (in MB) a dump will be created once automatically and written to the asset store. - "dumpTrigger": 0, + "dumpTriggerInMB": 0, // The path to the dotnet-gcdump tool binary. // @@ -334,7 +327,12 @@ "gcdumpTool": "", // When more memory is allocated than the defined value (in MB) a gcdump will be created once automatically and written to the asset store. - "gcumpTrigger": 0 + "gcumpTriggerInMB": 0, + + "gc": { + // The maximum number of megabyte that the process can consume until it is marked as not healthy. + "threshold": 8192 + } }, "assetStore": {