-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add Health Check for Runtime mode (#16715)
* Add Health Check for Runtime mode * Update src/Umbraco.Core/EmbeddedResources/Lang/en.xml Co-authored-by: Jason Elkin <jasonelkin86@gmail.com> * Update src/Umbraco.Core/HealthChecks/Checks/LiveEnvironment/RuntimeModeCheck.cs Co-authored-by: Jason Elkin <jasonelkin86@gmail.com> * Update lang file * Fix typo. --------- Co-authored-by: Jason Elkin <jasonelkin86@gmail.com>
- Loading branch information
1 parent
f20528c
commit 9a49ab7
Showing
4 changed files
with
59 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/Umbraco.Core/HealthChecks/Checks/LiveEnvironment/RuntimeModeCheck.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright (c) Umbraco. | ||
// See LICENSE for more details. | ||
|
||
using Microsoft.Extensions.Options; | ||
using Umbraco.Cms.Core.Configuration.Models; | ||
using Umbraco.Cms.Core.Services; | ||
using Umbraco.Extensions; | ||
|
||
namespace Umbraco.Cms.Core.HealthChecks.Checks.LiveEnvironment; | ||
|
||
/// <summary> | ||
/// Health check for the recommended production configuration for the runtime mode. | ||
/// </summary> | ||
[HealthCheck( | ||
"8E31E5C9-7A1D-4ACB-A3A8-6495F3EDB932", | ||
"Runtime Mode", | ||
Description = "The Production Runtime Mode disables development features and checks that settings are configured optimally for production.", | ||
Group = "Live Environment")] | ||
public class RuntimeModeCheck : AbstractSettingsCheck | ||
{ | ||
private readonly IOptionsMonitor<RuntimeSettings> _runtimeSettings; | ||
|
||
/// <summary> | ||
/// Initializes a new instance of the <see cref="RuntimeModeCheck" /> class. | ||
/// </summary> | ||
public RuntimeModeCheck(ILocalizedTextService textService, IOptionsMonitor<RuntimeSettings> runtimeSettings) | ||
: base(textService) => | ||
_runtimeSettings = runtimeSettings; | ||
|
||
/// <inheritdoc /> | ||
public override string ItemPath => Constants.Configuration.ConfigRuntimeMode; | ||
|
||
/// <inheritdoc /> | ||
public override ValueComparisonType ValueComparisonType => ValueComparisonType.ShouldEqual; | ||
|
||
/// <inheritdoc /> | ||
public override IEnumerable<AcceptableConfiguration> Values => new List<AcceptableConfiguration> | ||
{ | ||
new() { IsRecommended = true, Value = RuntimeMode.Production.ToString() }, | ||
}; | ||
|
||
/// <inheritdoc /> | ||
public override string CurrentValue => _runtimeSettings.CurrentValue.Mode.ToString(); | ||
|
||
/// <inheritdoc /> | ||
public override string CheckSuccessMessage => LocalizedTextService.Localize("healthcheck", "runtimeModeCheckSuccessMessage"); | ||
|
||
/// <inheritdoc /> | ||
public override string CheckErrorMessage => LocalizedTextService.Localize("healthcheck", "runtimeModeCheckErrorMessage"); | ||
|
||
/// <inheritdoc /> | ||
public override string ReadMoreLink => Constants.HealthChecks.DocumentationLinks.LiveEnvironment.RuntimeModeCheck; | ||
} |