2021-02-03 07:58:42 +01:00
|
|
|
|
// Copyright (c) Umbraco.
|
|
|
|
|
|
// See LICENSE for more details.
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic;
|
2020-10-21 10:29:25 +01:00
|
|
|
|
using Microsoft.Extensions.Options;
|
|
|
|
|
|
using Umbraco.Core.Configuration.Models;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
using Umbraco.Core.Services;
|
|
|
|
|
|
|
2021-02-03 07:58:42 +01:00
|
|
|
|
namespace Umbraco.Core.HealthChecks.Checks.LiveEnvironment
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
2021-02-03 07:58:42 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Health check for the configuration of debug-flag.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
[HealthCheck(
|
|
|
|
|
|
"61214FF3-FC57-4B31-B5CF-1D095C977D6D",
|
|
|
|
|
|
"Debug Compilation Mode",
|
2016-06-13 17:42:05 +02:00
|
|
|
|
Description = "Leaving debug compilation mode enabled can severely slow down a website and take up more memory on the server.",
|
|
|
|
|
|
Group = "Live Environment")]
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public class CompilationDebugCheck : AbstractSettingsCheck
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
2020-10-21 10:29:25 +01:00
|
|
|
|
private readonly IOptionsMonitor<HostingSettings> _hostingSettings;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2021-02-03 07:58:42 +01:00
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// Initializes a new instance of the <see cref="CompilationDebugCheck"/> class.
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public CompilationDebugCheck(ILocalizedTextService textService, IOptionsMonitor<HostingSettings> hostingSettings)
|
|
|
|
|
|
: base(textService) =>
|
2020-10-21 10:29:25 +01:00
|
|
|
|
_hostingSettings = hostingSettings;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2021-02-03 07:58:42 +01:00
|
|
|
|
/// <inheritdoc/>
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public override string ItemPath => Constants.Configuration.ConfigHostingDebug;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2021-02-03 07:58:42 +01:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override string ReadMoreLink => Constants.HealthChecks.DocumentationLinks.LiveEnvironment.CompilationDebugCheck;
|
|
|
|
|
|
|
|
|
|
|
|
/// <inheritdoc/>
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual;
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2021-02-03 07:58:42 +01:00
|
|
|
|
/// <inheritdoc/>
|
2016-09-01 19:06:08 +02:00
|
|
|
|
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration>
|
2016-06-13 17:42:05 +02:00
|
|
|
|
{
|
2020-10-21 10:29:25 +01:00
|
|
|
|
new AcceptableConfiguration
|
|
|
|
|
|
{
|
|
|
|
|
|
IsRecommended = true,
|
|
|
|
|
|
Value = bool.FalseString.ToLower()
|
|
|
|
|
|
}
|
2016-09-01 19:06:08 +02:00
|
|
|
|
};
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2021-02-03 07:58:42 +01:00
|
|
|
|
/// <inheritdoc/>
|
2020-10-21 10:29:25 +01:00
|
|
|
|
public override string CurrentValue => _hostingSettings.CurrentValue.Debug.ToString();
|
|
|
|
|
|
|
2021-02-03 07:58:42 +01:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override string CheckSuccessMessage => LocalizedTextService.Localize("healthcheck/compilationDebugCheckSuccessMessage");
|
2016-06-13 17:42:05 +02:00
|
|
|
|
|
2021-02-03 07:58:42 +01:00
|
|
|
|
/// <inheritdoc/>
|
|
|
|
|
|
public override string CheckErrorMessage => LocalizedTextService.Localize("healthcheck/compilationDebugCheckErrorMessage");
|
2016-06-13 17:42:05 +02:00
|
|
|
|
}
|
2017-07-20 11:21:28 +02:00
|
|
|
|
}
|