mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2026-02-09 09:16:41 +08:00
Added "service unavailable" support for the currently requested shell.
This commit is contained in:
@@ -382,7 +382,7 @@ namespace Orchard.Data.Migration.Interpreters {
|
||||
}
|
||||
}
|
||||
finally {
|
||||
_sqlStatements.Clear();
|
||||
_sqlStatements.Clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -12,6 +12,7 @@ using Orchard.Environment.Descriptor.Models;
|
||||
using Orchard.Localization;
|
||||
using Orchard.Logging;
|
||||
using Orchard.Mvc;
|
||||
using Orchard.Mvc.Extensions;
|
||||
using Orchard.Utility.Extensions;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
@@ -348,13 +349,18 @@ namespace Orchard.Environment {
|
||||
}
|
||||
|
||||
private void BlockRequestsDuringSetup() {
|
||||
if (_shellContexts == null)
|
||||
var httpContext = _httpContextAccessor.Current();
|
||||
if (httpContext.IsBackgroundContext())
|
||||
return;
|
||||
|
||||
// If there's only one tenant and it's initializing, return a Service Unavailable HTTP status code.
|
||||
var shellContexts = _shellContexts.ToList();
|
||||
if (shellContexts.Count == 1 && shellContexts[0].Settings.State == TenantState.Initializing) {
|
||||
var response = _httpContextAccessor.Current().Response;
|
||||
// Get the requested shell.
|
||||
var runningShell = _runningShellTable.Match(httpContext);
|
||||
if (runningShell == null)
|
||||
return;
|
||||
|
||||
// If the requested shell is currently initializing, return a Service Unavailable HTTP status code.
|
||||
if (runningShell.State == TenantState.Initializing) {
|
||||
var response = httpContext.Response;
|
||||
response.StatusCode = 503;
|
||||
response.StatusDescription = "Orchard is currently setting up. Please check back in a few moments.";
|
||||
response.Write("Orchard is currently setting up. Please check back in a few moments.");
|
||||
|
||||
@@ -94,7 +94,6 @@ namespace Orchard.Environment {
|
||||
SafelyTerminate(() => _sweepGenerator.Terminate());
|
||||
}
|
||||
|
||||
|
||||
private void SafelyTerminate(Action action) {
|
||||
try {
|
||||
action();
|
||||
|
||||
Reference in New Issue
Block a user