Created
November 5, 2012 22:52
-
-
Save sandrinodimattia/4020941 to your computer and use it in GitHub Desktop.
Setting preloadEnabled and startMode
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class WebRole : RoleEntryPoint | |
{ | |
public override void Run() | |
{ | |
using (var serverManager = new ServerManager()) | |
{ | |
var mainSite = serverManager.Sites[RoleEnvironment.CurrentRoleInstance.Id + "_Web"]; | |
var mainApplication = mainSite.Applications["/"]; | |
mainApplication["preloadEnabled"] = true; | |
var mainApplicationPool = serverManager.ApplicationPools[mainApplication.ApplicationPoolName]; | |
mainApplicationPool["startMode"] = "AlwaysRunning"; | |
serverManager.CommitChanges(); | |
} | |
base.Run(); | |
} | |
public override bool OnStart() | |
{ | |
// For information on handling configuration changes | |
// see the MSDN topic at http://go.microsoft.com/fwlink/?LinkId=166357. | |
return base.OnStart(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
We do have it in the WebRole, but still seeing the application restarting:
ShutDownMessage=HostingEnvironment initiated shutdown
HostingEnvironment caused shutdown
ShutDownStack= at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal()
at System.Web.Hosting.PipelineRuntime.StopProcessing()