Merge pull request #5815 from OrchardCMS/issue/recipeexecutiontimeout

Added configurable RecipeExecutionTimeout properties.
This commit is contained in:
Sébastien Ros
2015-09-17 12:06:04 -07:00
4 changed files with 28 additions and 5 deletions

View File

@@ -106,5 +106,19 @@
</Properties>
</Component>
<Component Type="Orchard.Setup.Controllers.SetupController">
<Properties>
<!-- Sets the request timeout to a configurable amount of seconds to give enough time to execute setup recipes. -->
<Property Name="RecipeExecutionTimeout" Value="600"/>
</Properties>
</Component>
<Component Type="Orchard.ImportExport.Providers.ImportActions.ExecuteRecipeAction">
<Properties>
<!-- Sets the request timeout to a configurable amount of seconds to give enough time to execute imported recipes. -->
<Property Name="RecipeExecutionTimeout" Value="600"/>
</Properties>
</Component>
</Components>
</HostComponents>

View File

@@ -51,6 +51,8 @@ namespace Orchard.ImportExport.Providers.ImportActions {
_sweepGenerator = sweepGenerator;
_recipeStepQueue = recipeStepQueue;
_recipeStepResultRepository = recipeStepResultRepository;
RecipeExecutionTimeout = 600;
}
public override string Name { get { return "ExecuteRecipe"; } }
@@ -58,6 +60,7 @@ namespace Orchard.ImportExport.Providers.ImportActions {
public XDocument RecipeDocument { get; set; }
public bool ResetSite { get; set; }
public string SuperUserPassword { get; set; }
public int RecipeExecutionTimeout { get; set; }
public override dynamic BuildEditor(dynamic shapeFactory) {
return UpdateEditor(shapeFactory, null);
@@ -149,8 +152,8 @@ namespace Orchard.ImportExport.Providers.ImportActions {
// Give each execution step a chance to augment the recipe step before it will be scheduled.
PrepareRecipe(recipeDocument);
// Sets the request timeout to 10 minutes to give enough time to execute custom recipes.
_orchardServices.WorkContext.HttpContext.Server.ScriptTimeout = 600;
// Sets the request timeout to a configurable amount of seconds to give enough time to execute custom recipes.
_orchardServices.WorkContext.HttpContext.Server.ScriptTimeout = RecipeExecutionTimeout;
// Suspend background task execution.
_sweepGenerator.Terminate();

View File

@@ -33,10 +33,12 @@ namespace Orchard.Setup.Controllers {
T = NullLocalizer.Instance;
Logger = NullLogger.Instance;
RecipeExecutionTimeout = 600;
}
public Localizer T { get; set; }
public ILogger Logger { get; set; }
public int RecipeExecutionTimeout { get; set; }
private ActionResult IndexViewResult(SetupViewModel model) {
return View(model);
@@ -70,8 +72,8 @@ namespace Orchard.Setup.Controllers {
[HttpPost, ActionName("Index")]
public ActionResult IndexPOST(SetupViewModel model) {
// Sets the setup request timeout to 10 minutes to give enough time to execute custom recipes.
HttpContext.Server.ScriptTimeout = 600;
// Sets the setup request timeout to a configurable amount of seconds to give enough time to execute custom recipes.
HttpContext.Server.ScriptTimeout = RecipeExecutionTimeout;
var recipes = _setupService.Recipes().ToList();

View File

@@ -135,6 +135,10 @@ namespace Orchard.Environment.ShellBuilders {
if (File.Exists(optionalShellConfig))
builder.RegisterModule(new ConfigurationSettingsReader(ConfigurationSettingsReaderConstants.DefaultSectionName, optionalShellConfig));
}
var optionalComponentsConfig = HostingEnvironment.MapPath("~/Config/HostComponents.config");
if (File.Exists(optionalComponentsConfig))
builder.RegisterModule(new HostComponentsConfigModule(optionalComponentsConfig));
});
}