Add IsRestarting property to Umbraco application notifications (#11883)

* Add IsRestarting property to Umbraco application notifications

* Add IUmbracoApplicationLifetimeNotification and update constructors

* Only subscribe to events on initial startup

* Cleanup CoreRuntime

* Do not reset StaticApplicationLogging instance after stopping/during restart
This commit is contained in:
Ronald Barendse
2022-01-25 06:38:20 +01:00
committed by GitHub
parent 4b92a47e93
commit ca56e0971f
6 changed files with 139 additions and 68 deletions

View File

@@ -1,16 +1,34 @@
using System;
namespace Umbraco.Cms.Core.Notifications
{
/// <summary>
/// Notification that occurs at the very end of the Umbraco boot process (after all <see cref="IComponent" />s are initialized).
/// </summary>
/// <seealso cref="Umbraco.Cms.Core.Notifications.INotification" />
public class UmbracoApplicationStartingNotification : INotification
/// <seealso cref="Umbraco.Cms.Core.Notifications.IUmbracoApplicationLifetimeNotification" />
public class UmbracoApplicationStartingNotification : IUmbracoApplicationLifetimeNotification
{
/// <summary>
/// Initializes a new instance of the <see cref="UmbracoApplicationStartingNotification" /> class.
/// </summary>
/// <param name="runtimeLevel">The runtime level</param>
public UmbracoApplicationStartingNotification(RuntimeLevel runtimeLevel) => RuntimeLevel = runtimeLevel;
[Obsolete("Use ctor with all params")]
public UmbracoApplicationStartingNotification(RuntimeLevel runtimeLevel)
: this(runtimeLevel, false)
{
// TODO: Remove this constructor in V10
}
/// <summary>
/// Initializes a new instance of the <see cref="UmbracoApplicationStartingNotification" /> class.
/// </summary>
/// <param name="runtimeLevel">The runtime level</param>
/// <param name="isRestarting">Indicates whether Umbraco is restarting.</param>
public UmbracoApplicationStartingNotification(RuntimeLevel runtimeLevel, bool isRestarting)
{
RuntimeLevel = runtimeLevel;
IsRestarting = isRestarting;
}
/// <summary>
/// Gets the runtime level.
@@ -19,5 +37,8 @@ namespace Umbraco.Cms.Core.Notifications
/// The runtime level.
/// </value>
public RuntimeLevel RuntimeLevel { get; }
/// <inheritdoc />
public bool IsRestarting { get; }
}
}