Merge branch 'netcore/feature/move-more-install-stuff' into netcore/feature/executable-backoffice
This commit is contained in:
@@ -20,11 +20,6 @@ namespace Umbraco.Core.Hosting
|
||||
string MapPath(string path);
|
||||
string ToAbsolute(string virtualPath, string root);
|
||||
|
||||
/// <summary>
|
||||
/// Terminates the current application. The application restarts the next time a request is received for it.
|
||||
/// </summary>
|
||||
void LazyRestartApplication();
|
||||
|
||||
void RegisterObject(IRegisteredObject registeredObject);
|
||||
void UnregisterObject(IRegisteredObject registeredObject);
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Core.Manifest
|
||||
{
|
||||
@@ -13,13 +14,13 @@ namespace Umbraco.Core.Manifest
|
||||
private static volatile bool _isRestarting;
|
||||
|
||||
private readonly ILogger _logger;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime;
|
||||
private readonly List<FileSystemWatcher> _fws = new List<FileSystemWatcher>();
|
||||
|
||||
public ManifestWatcher(ILogger logger, IHostingEnvironment hostingEnvironment)
|
||||
public ManifestWatcher(ILogger logger, IUmbracoApplicationLifetime umbracoApplicationLifetime)
|
||||
{
|
||||
_logger = logger ?? throw new ArgumentNullException(nameof(logger));
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_umbracoApplicationLifetime = umbracoApplicationLifetime;
|
||||
}
|
||||
|
||||
public void Start(params string[] packageFolders)
|
||||
@@ -57,7 +58,7 @@ namespace Umbraco.Core.Manifest
|
||||
|
||||
_isRestarting = true;
|
||||
_logger.Info<ManifestWatcher>("Manifest has changed, app pool is restarting ({Path})", e.FullPath);
|
||||
_hostingEnvironment.LazyRestartApplication();
|
||||
_umbracoApplicationLifetime.Restart();
|
||||
Dispose(); // uh? if the app restarts then this should be disposed anyways?
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,13 @@ namespace Umbraco.Net
|
||||
{
|
||||
public interface IUmbracoApplicationLifetime
|
||||
{
|
||||
/// <summary>
|
||||
/// A value indicating whether the application is restarting after the current request.
|
||||
/// </summary>
|
||||
bool IsRestarting { get; }
|
||||
/// <summary>
|
||||
/// Terminates the current application. The application restarts the next time a request is received for it.
|
||||
/// </summary>
|
||||
void Restart();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,6 +4,7 @@ using Umbraco.Core.Hosting;
|
||||
using Umbraco.Core.IO;
|
||||
using Umbraco.Core.Logging;
|
||||
using Umbraco.Core.Manifest;
|
||||
using Umbraco.Net;
|
||||
|
||||
namespace Umbraco.Core.Compose
|
||||
{
|
||||
@@ -12,18 +13,18 @@ namespace Umbraco.Core.Compose
|
||||
private readonly IRuntimeState _runtimeState;
|
||||
private readonly ILogger _logger;
|
||||
private readonly IIOHelper _ioHelper;
|
||||
private readonly IHostingEnvironment _hostingEnvironment;
|
||||
private readonly IUmbracoApplicationLifetime _umbracoApplicationLifetime;
|
||||
|
||||
// if configured and in debug mode, a ManifestWatcher watches App_Plugins folders for
|
||||
// package.manifest chances and restarts the application on any change
|
||||
private ManifestWatcher _mw;
|
||||
|
||||
public ManifestWatcherComponent(IRuntimeState runtimeState, ILogger logger, IIOHelper ioHelper, IHostingEnvironment hostingEnvironment)
|
||||
public ManifestWatcherComponent(IRuntimeState runtimeState, ILogger logger, IIOHelper ioHelper, IUmbracoApplicationLifetime umbracoApplicationLifetime)
|
||||
{
|
||||
_runtimeState = runtimeState;
|
||||
_logger = logger;
|
||||
_ioHelper = ioHelper;
|
||||
_hostingEnvironment = hostingEnvironment;
|
||||
_umbracoApplicationLifetime = umbracoApplicationLifetime;
|
||||
}
|
||||
|
||||
public void Initialize()
|
||||
@@ -36,7 +37,7 @@ namespace Umbraco.Core.Compose
|
||||
var appPlugins = _ioHelper.MapPath("~/App_Plugins/");
|
||||
if (Directory.Exists(appPlugins) == false) return;
|
||||
|
||||
_mw = new ManifestWatcher(_logger, _hostingEnvironment);
|
||||
_mw = new ManifestWatcher(_logger, _umbracoApplicationLifetime);
|
||||
_mw.Start(Directory.GetDirectories(appPlugins));
|
||||
}
|
||||
|
||||
|
||||
@@ -46,11 +46,6 @@ namespace Umbraco.Web.Hosting
|
||||
}
|
||||
|
||||
public string ToAbsolute(string virtualPath, string root) => VirtualPathUtility.ToAbsolute(virtualPath, root);
|
||||
public void LazyRestartApplication()
|
||||
{
|
||||
HttpRuntime.UnloadAppDomain();
|
||||
}
|
||||
|
||||
public void RegisterObject(IRegisteredObject registeredObject)
|
||||
{
|
||||
var wrapped = new RegisteredObjectWrapper(registeredObject);
|
||||
|
||||
Reference in New Issue
Block a user