Fix command host retry logic

--HG--
branch : dev
This commit is contained in:
Renaud Paquay
2010-07-23 12:45:24 -07:00
parent aae87c177f
commit 825320405c
2 changed files with 8 additions and 7 deletions

View File

@@ -42,18 +42,16 @@ namespace Orchard.Commands {
}
public int StartHost(TextReader input, TextWriter output) {
// This retry logic is not exactly clean, but a change in configuration
// sometimes need us to re-try initializing a host container.
Retry:
try {
_hostContainer = CreateHostContainer();
_tenants = new Dictionary<string, IStandaloneEnvironment>();
return 0;
}
catch (OrchardCommandHostRetryException e) {
output.WriteLine("{0} (Retrying...)", e.Message);
goto Retry;
// Special "Retry" return code for our host
output.WriteLine("{0}", e.Message);
output.WriteLine("(Retrying...)");
return 240;
}
catch (Exception e) {
for (; e != null; e = e.InnerException) {

View File

@@ -78,7 +78,10 @@ namespace Orchard {
var orchardDirectory = GetOrchardDirectory(_arguments.WorkingDirectory);
LogInfo("Orchard root directory: \"{0}\"", orchardDirectory.FullName);
return CreateHostAndExecute(orchardDirectory);
int result = CreateHostAndExecute(orchardDirectory);
if (result == 240/*special return code for "Retry"*/)
result = CreateHostAndExecute(orchardDirectory);
return result;
}
private int CreateHostAndExecute(DirectoryInfo orchardDirectory) {