mirror of
https://github.com/OrchardCMS/Orchard.git
synced 2025-11-24 16:53:10 +08:00
PE tasks list init and start background timer after PE tasks.
Fixes #6742
This commit is contained in:
@@ -203,6 +203,8 @@ namespace Orchard.Tests.Modules.Comments.Services {
|
||||
|
||||
public class ProcessingEngineStub : IProcessingEngine {
|
||||
|
||||
public void Initialize() { }
|
||||
|
||||
public string AddTask(ShellSettings shellSettings, ShellDescriptor shellDescriptor, string messageName, Dictionary<string, object> parameters) {
|
||||
return "";
|
||||
}
|
||||
|
||||
@@ -147,6 +147,10 @@ namespace Orchard.Environment {
|
||||
// Load all tenants, and activate their shell.
|
||||
if (allSettings.Any()) {
|
||||
Parallel.ForEach(allSettings, settings => {
|
||||
|
||||
_processingEngine.Initialize();
|
||||
ShellContext context = null;
|
||||
|
||||
for (var i = 0; i <= Retries; i++) {
|
||||
|
||||
// Not the first attempt, wait for a while ...
|
||||
@@ -157,10 +161,10 @@ namespace Orchard.Environment {
|
||||
}
|
||||
|
||||
try {
|
||||
var context = CreateShellContext(settings);
|
||||
context = CreateShellContext(settings);
|
||||
ActivateShell(context);
|
||||
|
||||
// If everything went well, return to stop the retry loop
|
||||
// If everything went well, break the retry loop
|
||||
break;
|
||||
}
|
||||
catch (Exception ex) {
|
||||
@@ -172,12 +176,18 @@ namespace Orchard.Environment {
|
||||
Logger.Error(ex, "A tenant could not be started: " + settings.Name + " Attempt number: " + i);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
while (_processingEngine.AreTasksPending()) {
|
||||
Logger.Debug("Processing pending task after activate Shell");
|
||||
_processingEngine.ExecuteNextTask();
|
||||
if (_processingEngine.AreTasksPending()) {
|
||||
|
||||
context.Shell.Sweep.Terminate();
|
||||
|
||||
while (_processingEngine.AreTasksPending()) {
|
||||
Logger.Debug("Processing pending task after activate Shell");
|
||||
_processingEngine.ExecuteNextTask();
|
||||
}
|
||||
|
||||
context.Shell.Sweep.Activate();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -50,6 +50,7 @@ namespace Orchard.Environment {
|
||||
}
|
||||
|
||||
public ILogger Logger { get; set; }
|
||||
public ISweepGenerator Sweep { get { return _sweepGenerator; } }
|
||||
|
||||
public void Activate() {
|
||||
var appBuilder = new AppBuilder();
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
using Orchard.Tasks;
|
||||
|
||||
namespace Orchard.Environment {
|
||||
public interface IOrchardShell {
|
||||
void Activate();
|
||||
void Terminate();
|
||||
ISweepGenerator Sweep { get; }
|
||||
}
|
||||
}
|
||||
@@ -22,6 +22,10 @@ namespace Orchard.Environment.State {
|
||||
_entries = new ContextState<IList<Entry>>("DefaultProcessingEngine.Entries", () => new List<Entry>());
|
||||
}
|
||||
|
||||
public void Initialize() {
|
||||
_entries.SetState(new List<Entry>());
|
||||
}
|
||||
|
||||
public string AddTask(ShellSettings shellSettings, ShellDescriptor shellDescriptor, string eventName, Dictionary<string, object> parameters) {
|
||||
|
||||
var entry = new Entry {
|
||||
|
||||
@@ -6,6 +6,11 @@ namespace Orchard.Environment.State
|
||||
{
|
||||
public interface IProcessingEngine
|
||||
{
|
||||
/// <summary>
|
||||
/// Init a new tasks list in the http context or in a new logical context.
|
||||
/// </summary>
|
||||
void Initialize();
|
||||
|
||||
/// <summary>
|
||||
/// Queue an event to fire inside of an explicitly decribed shell context
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user