Ask questionsFailed to gracefully shutdown application (IIS Hang)
on application pool recycle (automatic by duration) and under high load i often get the following entry in event log
Failed to gracefully shutdown application 'MACHINE/WEBROOT/APPHOST/WEBNAME'.
this was already happen in 2.1 with outproc, but now i've updated to 2.2 with hostingModel="InProcess", but i get a additional eventlog entry:
CoreCLR Version: 4.6.27207.3 Description: The process was terminated due to an unhandled exception. Exception Info: System.IO.IOException: The handle is invalid at System.ConsolePal.WindowsConsoleStream.Write(Byte buffer, Int32 offset, Int32 count) at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder) at System.IO.StreamWriter.WriteLine(String value) at System.IO.SyncTextWriter.WriteLine(String value) at System.Console.WriteLine(String value) at Microsoft.AspNetCore.Hosting.WebHostExtensions.<>c__DisplayClass6_0.<AttachCtrlcSigtermShutdown>g__Shutdown|0() at Microsoft.AspNetCore.Hosting.WebHostExtensions.<>c__DisplayClass6_0.<AttachCtrlcSigtermShutdown>b__1(Object sender, EventArgs eventArgs) at System.EventHandler.Invoke(Object sender, EventArgs e) at System.AppContext.OnProcessExit(Object sender, EventArgs e)
I use overlapped recycling, the new process is already stated, but i need to recycle manualy else the IIS is not processing requests anymore, they just timed out.
any idea why this exception happens? the related code should be this https://github.com/aspnet/Hosting/blob/master/src/Microsoft.AspNetCore.Hosting/WebHostExtensions.cs#L142 (this Console.Log)
Answer questions deanward81
This is affecting us quite badly during local development under 2.2. We're running under IIS using the in-process model and everytime the app pool needs to recycle (usually due to actual changes made during development) a build fails because files are locked by the process crash being handled.
We have to stop the app pool in IIS, build and then restart - this is painful! Are there any known workarounds in 2.2?