diff --git a/src/Umbraco.Configuration/ConfigsFactory.cs b/src/Umbraco.Configuration/ConfigsFactory.cs index 0b40da6947..edcafac497 100644 --- a/src/Umbraco.Configuration/ConfigsFactory.cs +++ b/src/Umbraco.Configuration/ConfigsFactory.cs @@ -21,6 +21,7 @@ namespace Umbraco.Core.Configuration public IExceptionFilterSettings ExceptionFilterSettings { get; } = new ExceptionFilterSettings(); public ITourSettings TourSettings { get; } = new TourSettings(); public ILoggingSettings LoggingSettings { get; } = new LoggingSettings(); + public IKeepAliveSettings KeepAliveSettings { get; } = new KeepAliveSettings(); public IUmbracoSettingsSection UmbracoSettings { get; } @@ -52,6 +53,7 @@ namespace Umbraco.Core.Configuration configs.Add(() => TourSettings); configs.Add(() => LoggingSettings); + configs.Add(() => KeepAliveSettings); configs.AddCoreConfigs(ioHelper); return configs; diff --git a/src/Umbraco.Configuration/Implementations/KeepAliveSettings.cs b/src/Umbraco.Configuration/Implementations/KeepAliveSettings.cs new file mode 100644 index 0000000000..0b8315d447 --- /dev/null +++ b/src/Umbraco.Configuration/Implementations/KeepAliveSettings.cs @@ -0,0 +1,10 @@ +using Umbraco.Core.Configuration.UmbracoSettings; + +namespace Umbraco.Configuration.Implementations +{ + internal class KeepAliveSettings : ConfigurationManagerConfigBase, IKeepAliveSettings + { + public bool DisableKeepAliveTask => UmbracoSettingsSection.KeepAlive.DisableKeepAliveTask; + public string KeepAlivePingUrl => UmbracoSettingsSection.KeepAlive.KeepAlivePingUrl; + } +} diff --git a/src/Umbraco.Configuration/UmbracoSettings/KeepAliveElement.cs b/src/Umbraco.Configuration/UmbracoSettings/KeepAliveElement.cs index 89ba9be54d..2297fb4e20 100644 --- a/src/Umbraco.Configuration/UmbracoSettings/KeepAliveElement.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/KeepAliveElement.cs @@ -2,7 +2,7 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - internal class KeepAliveElement : ConfigurationElement, IKeepAliveSection + internal class KeepAliveElement : ConfigurationElement, IKeepAliveSettings { [ConfigurationProperty("disableKeepAliveTask", DefaultValue = "false")] public bool DisableKeepAliveTask => (bool)base["disableKeepAliveTask"]; diff --git a/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs b/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs index 9187cecd40..11b4b8fc39 100644 --- a/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs +++ b/src/Umbraco.Configuration/UmbracoSettings/UmbracoSettingsSection.cs @@ -32,7 +32,5 @@ namespace Umbraco.Core.Configuration.UmbracoSettings IRequestHandlerSection IUmbracoSettingsSection.RequestHandler => RequestHandler; IWebRoutingSection IUmbracoSettingsSection.WebRouting => WebRouting; - - IKeepAliveSection IUmbracoSettingsSection.KeepAlive => KeepAlive; } } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IKeepAliveSection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IKeepAliveSettings.cs similarity index 68% rename from src/Umbraco.Core/Configuration/UmbracoSettings/IKeepAliveSection.cs rename to src/Umbraco.Core/Configuration/UmbracoSettings/IKeepAliveSettings.cs index 3a0ad258c5..58a8151474 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IKeepAliveSection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IKeepAliveSettings.cs @@ -1,6 +1,6 @@ namespace Umbraco.Core.Configuration.UmbracoSettings { - public interface IKeepAliveSection : IUmbracoConfigurationSection + public interface IKeepAliveSettings : IUmbracoConfigurationSection { bool DisableKeepAliveTask { get; } string KeepAlivePingUrl { get; } diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettingsSection.cs b/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettingsSection.cs index ff11d223ac..e6fd76b72e 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettingsSection.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings/IUmbracoSettingsSection.cs @@ -11,7 +11,5 @@ namespace Umbraco.Core.Configuration.UmbracoSettings IRequestHandlerSection RequestHandler { get; } IWebRoutingSection WebRouting { get; } - - IKeepAliveSection KeepAlive { get; } } } diff --git a/src/Umbraco.Core/Scheduling/KeepAlive.cs b/src/Umbraco.Core/Scheduling/KeepAlive.cs index c677c66b83..515251b105 100644 --- a/src/Umbraco.Core/Scheduling/KeepAlive.cs +++ b/src/Umbraco.Core/Scheduling/KeepAlive.cs @@ -12,16 +12,16 @@ namespace Umbraco.Web.Scheduling public class KeepAlive : RecurringTaskBase { private readonly IRuntimeState _runtime; - private readonly IKeepAliveSection _keepAliveSection; + private readonly IKeepAliveSettings _keepAliveSettings; private readonly IProfilingLogger _logger; private static HttpClient _httpClient; public KeepAlive(IBackgroundTaskRunner runner, int delayMilliseconds, int periodMilliseconds, - IRuntimeState runtime, IKeepAliveSection keepAliveSection, IProfilingLogger logger) + IRuntimeState runtime, IKeepAliveSettings keepAliveSettings, IProfilingLogger logger) : base(runner, delayMilliseconds, periodMilliseconds) { _runtime = runtime; - _keepAliveSection = keepAliveSection; + _keepAliveSettings = keepAliveSettings; _logger = logger; if (_httpClient == null) _httpClient = new HttpClient(); @@ -49,7 +49,7 @@ namespace Umbraco.Web.Scheduling using (_logger.DebugDuration("Keep alive executing", "Keep alive complete")) { - var keepAlivePingUrl = _keepAliveSection.KeepAlivePingUrl; + var keepAlivePingUrl = _keepAliveSettings.KeepAlivePingUrl; try { if (keepAlivePingUrl.Contains("{umbracoApplicationUrl}")) diff --git a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs index a1385257e9..1d4a654830 100644 --- a/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs +++ b/src/Umbraco.Infrastructure/Scheduling/SchedulerComponent.cs @@ -35,11 +35,11 @@ namespace Umbraco.Web.Scheduling private readonly HealthCheckNotificationMethodCollection _notifications; private readonly IUmbracoContextFactory _umbracoContextFactory; private readonly IHealthChecks _healthChecksConfig; - private readonly IUmbracoSettingsSection _umbracoSettingsSection; private readonly IIOHelper _ioHelper; private readonly IServerMessenger _serverMessenger; private readonly IRequestAccessor _requestAccessor; private readonly ILoggingSettings _loggingSettings; + private readonly IKeepAliveSettings _keepAliveSettings; private BackgroundTaskRunner _keepAliveRunner; private BackgroundTaskRunner _publishingRunner; @@ -57,8 +57,8 @@ namespace Umbraco.Web.Scheduling HealthCheckCollection healthChecks, HealthCheckNotificationMethodCollection notifications, IScopeProvider scopeProvider, IUmbracoContextFactory umbracoContextFactory, IProfilingLogger logger, IHostingEnvironment hostingEnvironment, IHealthChecks healthChecksConfig, - IUmbracoSettingsSection umbracoSettingsSection, IIOHelper ioHelper, IServerMessenger serverMessenger, IRequestAccessor requestAccessor, - ILoggingSettings loggingSettings) + IIOHelper ioHelper, IServerMessenger serverMessenger, IRequestAccessor requestAccessor, + ILoggingSettings loggingSettings, IKeepAliveSettings keepAliveSettings) { _runtime = runtime; _contentService = contentService; @@ -71,11 +71,11 @@ namespace Umbraco.Web.Scheduling _healthChecks = healthChecks; _notifications = notifications; _healthChecksConfig = healthChecksConfig ?? throw new ArgumentNullException(nameof(healthChecksConfig)); - _umbracoSettingsSection = umbracoSettingsSection; _ioHelper = ioHelper; _serverMessenger = serverMessenger; _requestAccessor = requestAccessor; _loggingSettings = loggingSettings; + _keepAliveSettings = keepAliveSettings; } public void Initialize() @@ -114,13 +114,12 @@ namespace Umbraco.Web.Scheduling LazyInitializer.EnsureInitialized(ref _tasks, ref _started, ref _locker, () => { _logger.Debug("Initializing the scheduler"); - var settings = _umbracoSettingsSection; var tasks = new List(); - if (settings.KeepAlive.DisableKeepAliveTask == false) + if (_keepAliveSettings.DisableKeepAliveTask == false) { - tasks.Add(RegisterKeepAlive(settings.KeepAlive)); + tasks.Add(RegisterKeepAlive(_keepAliveSettings)); } tasks.Add(RegisterScheduledPublishing()); @@ -135,11 +134,11 @@ namespace Umbraco.Web.Scheduling }); } - private IBackgroundTask RegisterKeepAlive(IKeepAliveSection keepAliveSection) + private IBackgroundTask RegisterKeepAlive(IKeepAliveSettings keepAliveSettings) { // ping/keepalive // on all servers - var task = new KeepAlive(_keepAliveRunner, DefaultDelayMilliseconds, FiveMinuteMilliseconds, _runtime, keepAliveSection, _logger); + var task = new KeepAlive(_keepAliveRunner, DefaultDelayMilliseconds, FiveMinuteMilliseconds, _runtime, keepAliveSettings, _logger); _keepAliveRunner.TryAdd(task); return task; }