Installation and deployment Questions on installation, system configuration and deployment to the live server.
Version 4.x > Installation and deployment > HostingEnvironment initiated shutdown errors View modes: 
User avatar
Certified Marketer 12
Certified Marketer 12
james-distinctionhq - 12/16/2009 1:40:29 PM
   
HostingEnvironment initiated shutdown errors
I see this mentioned in a few other posts, but none of them have a suitable solution.

I'm also discussing this via email with Kentico but thought I'd open it up on here too.

Background info... running Kentico 4.1 latest build, on a Win 2008 OS with IIS7 and SQL Server 2005 - all latest patches applied. Only 1 site on the entire box with 4GB ram.

The error in the Kentico log is:
EventType: E
EventTime: 12/16/2009 4:39:38 PM
Source: Application_End
EventCode: EXCEPTION
EventDescription: Message: HostingEnvironment initiated shutdown
HostingEnvironment caused shutdown<br />
Shutdown stack: at System.Environment.GetStackTrace(Exception e, Boolean needFileInfo)
at System.Environment.get_StackTrace()
at System.Web.Hosting.HostingEnvironment.InitiateShutdownInternal()
at System.Web.Hosting.HostingEnvironment.InitiateShutdown()
at System.Web.Hosting.PipelineRuntime.StopProcessing()<br />
Call stack: at Global.LogApplicationEnd()
at Global.Application_End(Object sender, EventArgs e)
at System.RuntimeMethodHandle._InvokeMethodFast(Object target, Object[] arguments, SignatureStruct& sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.RuntimeMethodHandle.InvokeMethodFast(Object target, Object[] arguments, Signature sig, MethodAttributes methodAttributes, RuntimeTypeHandle typeOwner)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture, Boolean skipVisibilityChecks)
at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
at System.Web.HttpApplication.ProcessSpecialRequest(HttpContext context, MethodInfo method, Int32 paramCount, Object eventSource, EventArgs eventArgs, HttpSessionState session)
at System.Web.HttpApplicationFactory.FireApplicationOnEnd()
at System.Web.HttpApplicationFactory.Dispose()
at System.Web.HttpRuntime.Dispose()
at System.Web.HttpRuntime.ReleaseResourcesAndUnloadAppDomain(Object state)
at System.Threading._ThreadPoolWaitCallback.WaitCallback_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallbackInternal(_ThreadPoolWaitCallback tpWaitCallBack)
at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback(Object state)

We typically get one of two types of errors on the windows system log:

The worker processes serving application pool 'xyz.com(domain)(2.0)(pool)' are being recycled due to 1 or more configuration changes in the application pool properties which necessitate a restart of the processes.

A worker process with process id of '4796' serving application pool 'xyz.com(domain)(2.0)(pool)' has requested a recycle because it reached its virtual memory limit.

I'm not sure why there are any 'configuration changes', or why the worker process should reach a 4GB limit - not ever.

Would be great to hear any feedback or from people with similar problems.

James

User avatar
Member
Member
Alex Rybin - 12/16/2009 2:00:14 PM
   
RE:HostingEnvironment initiated shutdown errors
That is normal.
WorkerProcess is shuted down due inactivity for 20 minutes (usually).

You can change this in Advanced Properties of the Application Pool: Process Model -> Idle Time-out.

User avatar
Certified Marketer 12
Certified Marketer 12
james-distinctionhq - 12/16/2009 2:09:06 PM
   
RE:HostingEnvironment initiated shutdown errors
I should have said that these errors occur sporadically, even during periods of activity.

We have full control over the server, have removed the 20 min timeout, etc all to no avail.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 12/17/2009 2:56:58 AM
   
RE:HostingEnvironment initiated shutdown errors
Hi,

There are several possible causes of these issue, mostly caused by .Net framework or seetings on app pool.

- The application pool in IIS can be set to recycle the application if some limits are exceeded - CPU usage, Memory, idle time.

- .Net is restarting application automatically when there is a change in web.config file, BIN, App_Code directory and other directories (you can find complete list using Google). From the error message it seems that some directory on file system in the web project folder was changed and this invoked the restart of the application. This is the standard .Net behavior (bluedragon.blog-city.com/why_might_a_net_web_application_app_domain_restart_the_reaso.htm).
- Last possible option is that the number of recompilation is reached. Net framework is restarting automatically the application after a specified number of compilations is reached - e.g. you have edited some code files, etc. This can be set in web.config file, default value is 100:
<compilation debug="false" numRecompilesBeforeAppRestart="100">

Best Regards,
Juraj Ondrus

User avatar
Certified Marketer 12
Certified Marketer 12
james-distinctionhq - 12/17/2009 6:29:11 AM
   
RE:HostingEnvironment initiated shutdown errors
Hi Juraj,

Thanks for that, and the email from Helena. I've passed the info on to our server admin so will keep you updated.

User avatar
Member
Member
scottmc101-hotmail - 12/31/2009 7:01:16 PM
   
RE:HostingEnvironment initiated shutdown errors
Hi James,
Any update on this? We have been seeing the exact same issue and can't seem to find a clear resolution. If you have had any luck, can you please post and let me know what it is you did to resolve the problem?

Thank you!

User avatar
Certified Marketer 12
Certified Marketer 12
james-distinctionhq - 1/4/2010 3:06:58 AM
   
RE:HostingEnvironment initiated shutdown errors
No solution as yet - it's driving us mad to be honest with you. There doesn't appear to be any logic of why it's happening.

The hosts are suggesting it's a Kentico issue, and Kentico are suggesting it's a server issue. Neither seems to know how to fix it.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/4/2010 5:36:57 AM
   
RE:HostingEnvironment initiated shutdown errors
Hi,

What was the response from your hosts? Is it possible to send us any memory dumps from the server so we can see what is going on when the application is restarted? In my previous post I have suggested the things I found using Google - basically the restart is invoked by the .Net framework and by the hosting environment, but it is also possible that the application (CMS) did something bad, so we need the memory dumps to see the details. Thank you.

Best Regards,
Juraj Ondrus

User avatar
Certified Marketer 12
Certified Marketer 12
james-distinctionhq - 1/4/2010 5:58:43 AM
   
RE:HostingEnvironment initiated shutdown errors
Hi Juraj,

The hosts simply said that the problem did not appear to be an IIS issue - they suggested that Kentico might be consuming all the resources and forcing a recycle... but the server has 4GB of memory and very low traffic.

Can you explain how to provide a memory dump?

The most recent event log is below for your info (it might help others) - the hosting environment wasn't shutting down, so it's really confusing.
Log Name: Application
Source: ASP.NET 2.0.50727.0
Date: 04/01/2010 11:35:59
Event ID: 1305
Task Category: Web Event
Level: Information
Keywords: Classic
User: N/A
Computer: distinctiondedi
Description:
Event code: 1002
Event message: Application is shutting down. Reason: Hosting environment is shutting down.
Event time: 04/01/2010 11:35:59
Event time (UTC): 04/01/2010 11:35:59
Event ID: 8d61521cc241435a91c01dfb908649cb
Event sequence: 138
Event occurrence: 1
Event detail code: 50002

Application information:
Application domain: /LM/W3SVC/7087/ROOT-1-129070772387705000
Trust level: Full
Application Virtual Path: /
Application Path: C:\inetpub\vhosts\website.co.uk\httpdocs\
Machine name: DISTINCTIONDEDI

Process information:
Process ID: 5888
Process name: w3wp.exe
Account name: DISTINCTIONDEDI\IWPD_2(ftp_user)

Custom event details:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="ASP.NET 2.0.50727.0" />
<EventID Qualifiers="16384">1305</EventID>
<Level>4</Level>
<Task>3</Task>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2010-01-04T11:35:59.000Z" />
<EventRecordID>718596</EventRecordID>
<Channel>Application</Channel>
<Computer>distinctiondedi</Computer>
<Security />
</System>
<EventData>
<Data>1002</Data>
<Data>Application is shutting down. Reason: Hosting environment is shutting down.</Data>
<Data>04/01/2010 11:35:59</Data>
<Data>04/01/2010 11:35:59</Data>
<Data>8d61521cc241435a91c01dfb908649cb</Data>
<Data>138</Data>
<Data>1</Data>
<Data>50002</Data>
<Data>/LM/W3SVC/7087/ROOT-1-129070772387705000</Data>
<Data>Full</Data>
<Data>/</Data>
<Data>C:\inetpub\vhosts\domain.co.uk\httpdocs\</Data>
<Data>DISTINCTIONDEDI</Data>
<Data>
</Data>
<Data>5888</Data>
<Data>w3wp.exe</Data>
<Data>DISTINCTIONDEDI\IWPD_2(ftp_user)</Data>
</EventData>
</Event>

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 1/5/2010 2:35:27 AM
   
RE:HostingEnvironment initiated shutdown errors
Hi,

I have googled the error message again and most of the posts are reffering to the Idle time set in IIS. Could you please check this setting and compare it with the time period of the shutdowns? As you mentioned that there is a low traffic, so it is possible that the application is being killed due to the idle time.

And how to get memory dump - you can find lots of articles using Google, for example:

http://support.kaspersky.com/kis2009/error?qid=193238549
http://support.microsoft.com/kb/254649
http://support.microsoft.com/kb/315263
http://www.novell.com/support/search.do?cmd=displayKC&docType=kc&externalId=7004093&sliceId=1&docTypeID=DT_TID_1_1

Thank you.

Best Regrads,
Juraj Ondrus

User avatar
Member
Member
Mark - 10/27/2010 2:41:05 PM
   
RE:HostingEnvironment initiated shutdown errors
I have noticed this behavior too and after checking the IIS settings, your explanation makes sense for my situation.

Thanks,
Mark