diff --git a/src/Umbraco.Core/ApplicationContext.cs b/src/Umbraco.Core/ApplicationContext.cs index 610af5380e..f67587d8fa 100644 --- a/src/Umbraco.Core/ApplicationContext.cs +++ b/src/Umbraco.Core/ApplicationContext.cs @@ -36,6 +36,7 @@ namespace Umbraco.Core // note - the original umbraco module checks on content.Instance in umbraco.dll // now, the boot task that setup the content store ensures that it is ready bool _isReady = false; + System.Threading.ManualResetEventSlim _isReadyEvent = new System.Threading.ManualResetEventSlim(false); public bool IsReady { get @@ -46,9 +47,15 @@ namespace Umbraco.Core { AssertIsNotReady(); _isReady = value; + _isReadyEvent.Set(); } } + public bool WaitForReady(int timeout) + { + return _isReadyEvent.WaitHandle.WaitOne(timeout); + } + // notes // GlobalSettings.ConfigurationStatus returns the value that's in the web.config, so it's the "configured version" diff --git a/src/Umbraco.Core/Configuration/UmbracoSettings.cs b/src/Umbraco.Core/Configuration/UmbracoSettings.cs index 2a1d6f00a7..e3db7573d3 100644 --- a/src/Umbraco.Core/Configuration/UmbracoSettings.cs +++ b/src/Umbraco.Core/Configuration/UmbracoSettings.cs @@ -145,14 +145,9 @@ namespace Umbraco.Core.Configuration /// internal static string BootSplashPage { - get { return "~/default.aspx"; } + get { return "~/config/splashes/booting.aspx"; } } - internal static string NoContentSplashPage - { - get { return "~/config/splashes/noNodes.aspx"; } - } - /// /// Gets a value indicating whether logging is enabled in umbracoSettings.config (/settings/logging/enableLogging). /// diff --git a/src/Umbraco.Core/CoreBootManager.cs b/src/Umbraco.Core/CoreBootManager.cs index 58e18828c9..d7d5b49838 100644 --- a/src/Umbraco.Core/CoreBootManager.cs +++ b/src/Umbraco.Core/CoreBootManager.cs @@ -33,10 +33,7 @@ namespace Umbraco.Core _timer = DisposableTimer.Start(x => LogHelper.Info("Umbraco application startup complete" + " (took " + x + "ms)")); //create the ApplicationContext - ApplicationContext = ApplicationContext.Current = new ApplicationContext() - { - IsReady = true // fixme - }; + ApplicationContext = ApplicationContext.Current = new ApplicationContext(); InitializeResolvers(); diff --git a/src/Umbraco.Web.UI/config/splashes/booting.aspx b/src/Umbraco.Web.UI/config/splashes/booting.aspx index 75e74410e9..39e97e4ffe 100644 --- a/src/Umbraco.Web.UI/config/splashes/booting.aspx +++ b/src/Umbraco.Web.UI/config/splashes/booting.aspx @@ -1,19 +1,18 @@ -<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="booting.aspx.cs" Inherits="umbraco.presentation.config.splashes.booting" %> +<%@ Page Language="C#" AutoEventWireup="true" Inherits="System.Web.UI.Page" %> - Website booting - "> + The website is restarting + "> -

Website is restarting

-

The webpage cannot be displayed right now.

-

This page will refresh in ten seconds.

+

The website is restarting

+

Please wait for 10s while we prepare to serve the page you have requested...

-
-

You can modify the design of this page by editing /config/splashes/booting.aspx

-
+

+ You can modify the design of this page by editing /config/splashes/booting.aspx +

diff --git a/src/Umbraco.Web/UmbracoModule.cs b/src/Umbraco.Web/UmbracoModule.cs index d35cd99f91..db5286a7ad 100644 --- a/src/Umbraco.Web/UmbracoModule.cs +++ b/src/Umbraco.Web/UmbracoModule.cs @@ -283,52 +283,58 @@ namespace Umbraco.Web // if yes, return true bool EnsureIsReady(HttpContextBase httpContext, Uri uri) { + var ready = ApplicationContext.Current.IsReady; + // ensure we are ready - if (!ApplicationContext.Current.IsReady) + if (!ready) { LogHelper.Warn("Umbraco is not ready"); - httpContext.Response.StatusCode = 503; - - // fixme - default.aspx has to be ready for RequestContext.DocumentRequest==null - // fixme - in fact we should transfer to an empty html page... - var bootUrl = UriUtility.ToAbsolute(UmbracoSettings.BootSplashPage); - - if (UmbracoSettings.EnableSplashWhileLoading) // legacy - should go + if (!UmbracoSettings.EnableSplashWhileLoading) { - var configPath = UriUtility.ToAbsolute(SystemDirectories.Config); - bootUrl = string.Format("{0}/splashes/booting.aspx?url={1}", configPath, HttpUtility.UrlEncode(uri.ToString())); - // fixme ?orgurl=... ?retry=... + // let requests pile up and wait for 10s then show the splash anyway + ready = ApplicationContext.Current.WaitForReady(10 * 1000); } - httpContext.RewritePath(bootUrl); + if (!ready) + { + httpContext.Response.StatusCode = 503; - return false; + var bootUrl = UmbracoSettings.BootSplashPage; + if (string.IsNullOrWhiteSpace(bootUrl)) + bootUrl = "~/config/splashes/booting.aspx"; + httpContext.RewritePath(UriUtility.ToAbsolute(bootUrl) + "?url=" + HttpUtility.UrlEncode(uri.ToString())); + + return false; + } } return true; } - // ensures Umbraco has at least one published node - // if not, rewrites to splash and return false - // if yes, return true - bool EnsureHasContent(HttpContextBase httpContext) - { - var context = UmbracoContext.Current; - var store = context.RoutingContext.PublishedContentStore; - if (!store.HasContent(context)) - { - LogHelper.Warn("Umbraco has not content"); + // ensures Umbraco has at least one published node + // if not, rewrites to splash and return false + // if yes, return true + bool EnsureHasContent(HttpContextBase httpContext) + { + var context = UmbracoContext.Current; + var store = context.RoutingContext.PublishedContentStore; + if (!store.HasContent(context)) + { + LogHelper.Warn("Umbraco has no content"); - var noContentUrl = UriUtility.ToAbsolute(UmbracoSettings.NoContentSplashPage); - httpContext.RewritePath(noContentUrl); - return false; - } - else - { - return true; - } - } + httpContext.Response.StatusCode = 503; + + var noContentUrl = "~/config/splashes/noNodes.aspx"; + httpContext.RewritePath(UriUtility.ToAbsolute(noContentUrl)); + + return false; + } + else + { + return true; + } + } // ensures Umbraco is configured // if not, redirect to install and return false diff --git a/src/Umbraco.Web/WebBootManager.cs b/src/Umbraco.Web/WebBootManager.cs index 36c4b2ff44..5c4184e7c5 100644 --- a/src/Umbraco.Web/WebBootManager.cs +++ b/src/Umbraco.Web/WebBootManager.cs @@ -108,6 +108,9 @@ namespace Umbraco.Web ApplicationEventsResolver.Current.ApplicationEventHandlers .ForEach(x => x.OnApplicationStarted(_umbracoApplication, ApplicationContext)); + // we're ready to serve content! + ApplicationContext.IsReady = true; + return this; }