Fixing tenant load retry logic

This commit is contained in:
Sebastien Ros
2016-03-16 16:34:32 -07:00
parent dd326127ce
commit 9a2c08d31e

View File

@@ -146,26 +146,28 @@ namespace Orchard.Environment {
// Not the first attempt, wait for a while ...
if (DelayRetries && i > 0) {
// Waits for i^2 which means 1, 2, 4, 8 ... seconds
// Wait for i^2 which means 1, 2, 4, 8 ... seconds
Thread.Sleep(TimeSpan.FromSeconds(Math.Pow(i, 2)));
}
bool failed = false;
try {
var context = CreateShellContext(settings);
ActivateShell(context);
}
catch (Exception ex) {
// An exception at this point is always fatal as it literally kills the
// tenant. What is more fatal than something that kills you?
Logger.Error(ex, "A tenant could not be started: " + settings.Name + " Attempt number: " + i);
failed = true;
}
if(failed && i == Retries) {
Logger.Fatal("A tenant could not be started: {0} after {1} retries.", settings.Name, Retries);
// If everything went well, return to stop the retry loop
return;
}
catch (Exception ex) {
if (i == Retries) {
Logger.Fatal("A tenant could not be started: {0} after {1} retries.", settings.Name, Retries);
return;
}
else {
Logger.Error(ex, "A tenant could not be started: " + settings.Name + " Attempt number: " + i);
}
}
}
while (_processingEngine.AreTasksPending()) {