Skip to content

Instantly share code, notes, and snippets.

@sandrinodimattia
Created November 5, 2012 22:52
Show Gist options
  • Save sandrinodimattia/4020941 to your computer and use it in GitHub Desktop.
Save sandrinodimattia/4020941 to your computer and use it in GitHub Desktop.
Setting preloadEnabled and startMode
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();
}
}
@LazyDeveloper-zz
Copy link

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()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment