-
Notifications
You must be signed in to change notification settings - Fork 312
IApplicationLifetime ApplicationStopped events not getting called when stopping/restarting Azure web app #846
Comments
@rogerdawson Could you provide a simple repro app? @JunTaoLuo can give it a try. |
Hello, I haven't got anything to hand as its embedded in our main app. I'm guessing a standard RTM web app will reproduce the error but the problem will be you'll need a database to log messages to or some other means by which you can detect if the shutdown method has been called. If you haven't got anything like that to hand then I guess I could try and create something. Let me know how you would prefer to proceed. Many Thanks, Roger |
@rogerdawson it would be great if you could share a simple repro app on github for us to investigate. Thanks! |
As said by OP, none of the shutdown events actually fire, when using IIS Express. During debugging with Visual Studio, neither clicking on "Stop Debugging" button in VS, nor right-clicking IIS Express icon in tray and choosing Stop Site/Exit, trigger the event. These thing is just not working! And who runs Kestrel in a console?!... |
Hi, I'm a bit snowed under at the moment so I can't produce anything Thanks, Roger On 8 September 2016 at 21:58, Murat Girgin [email protected] wrote:
Roger Dawson GA Digital Ltd T: +44 (0)1202 619102 <%2B44%20%280%291425%20270970> M: +44 _W: _www.ga-inst.co.uk http://www.ga-inst.co.uk/\ E: This e-mail and any attachment is intended for the named addressee(s) only, GA Digital Ltd is registered in England under registered number 06530309 |
@rogerdawson As a workaround (or substitute) did you have any luck trying a subscription to Unloading/ProcessExit? https://github.com/dotnet/corefx/issues/10012#issuecomment-232436326 |
Hi @guardrex , no, I haven't tried that. We've bailed from running our back-end service as a web app as it's just too unreliable - we've had no end of problems with intermittent restarts or the app services (see WEBSITE_LOCAL_CACHE_OPTION for instance which is necessary due to Azure network storage 'glitches'). Web jobs wasn't any better to be honest. We are running as service on a VM now and as well as better reliability we have found performance is almost twice as good (running on a 2-core D2_V2) as opposed to our service plan which was a 4-core S3. Our system is mostly IO bound so we guess this is down to networking. The service is still running as a web app but we now get clean shutdowns (same code, but Windows obviously shuts the service down gracefully so it must be Azure that isn't shutting down the web app gracefully). Thanks for the advice though. |
I'm having the same problem. Here's a repro app: https://github.com/tomazv/applifetime It writes events to a log and displays the log on each request. It only logs "Application started" and "Before run" but no other events when stopping or restaring the site on Azure. |
See: aspnet/IISIntegration#279 this has been fixed in 1.1 preview of AspNetCoreModule (which won't be deployed to Azure until 1.1 stable releases). Can you reproduce this issue outside of Azure? If so you can try it with 1.1-preview1 https://blogs.msdn.microsoft.com/webdev/2016/10/25/announcing-asp-net-core-1-1-preview-1/ |
I have reproduced this issue on IIS (Windows Server 2016) and can confirm it has been fixed in 1.1 preview. |
Awesome! |
Hi there. When will 1.1 be deployed to Azure production? Thank you |
@Plasma 1.1 is already on Azure App Service. Are you having issues deploying? |
@muratg Deploying OK, its just the ApplicationStopping/Stopped events are not firing still. The Started event works. |
And does it work locally when you're on 1.1? |
What's the test procedure for that, just pressing Stop under VS2017 debugger? I don't run it under IIS its just IIS Express. Cheers. |
@Plasma You can put a break point on the events you'd like to capture. Or you can log in those events and make sure to see the log lines for the events. IIS vs IIS Express shouldn't be a problem. Also, make sure you're on 1.1 :) |
@muratg I tried putting a breakpoint on a method that also logs to disk when hit, but the breakpoint is not hit when I either press the Stop button in VS2017 (as expected, I'd assume this is a hard terminate), nor when I click 'Stop site' using IIS Express's system tray. I'm using .NET Core 1.1 under 'Target framework'. Am I supposed to be doing anything special (inherit from a base class, currently I dont inherit from anything for my Startup class, call a method, etc) in order to support these events? ApplicationStarted fires without an issue. |
I'm having same issue. ApplicationStopped and ApplicationStopping event dosen't fire when run in Azure Web App and IIS Express. |
Re-opening based on the most recent comments. @Tratcher could you take a look? |
@Plasma @lennynas how are you stopping the site in AWA and IIS Express? |
@Tratcher in Azure it's either the Stop or Restart button or deployment (that must cause a stop somewhere during the update). For express I tried both "Stop site" under the IIS Express tray icon for the site as well as pressing Stop under VS2017 debugger while debugging. |
I have also opened an issue about this here. One thing I'd like to add: in Azure, none of these methods are called even when I'm using the App_Offline.htm file. |
@Tratcher is there anything I can do to assist in helping you debug? Thanks |
I've confirmed with the IIS Express owners that it does not implement any graceful shutdown mechanics so no shutdown events are expected there. I'll follow up on the Azure scenario. |
I tested on a private stamp. After executing StopWebSite command, ANCM did send ctrl signal to the backend and my test Kestrel app exited as expected. @Plasma, when you stopped your azure site, was there still some on-flying requests? |
Hi @pan-wang . I doubt it, as I was testing before any live traffic was hitting the service. Should that matter? Thanks I could look at preparing an example project if needed. |
@pan-wang also worth noting I tested (and expected) the Stopping/Stopped events to take place during scale in/out, stop, start, restart and site deployment requests when updating the code. |
I debugged and confirmed that send signal failed on Antares. I am investigating the root cause. Will update the thread ASAP.
On 2017-06-13 22:15 , Andrew Armstrong<mailto:[email protected]> Wrote:
@pan-wang<https://github.com/pan-wang> also worth noting I tested (and expected) the Stopping/Stopped events to take place during scale in/out, stop, start, restart and site deployment requests when updating the code.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub<#846 (comment)>, or mute the thread<https://github.com/notifications/unsubscribe-auth/ARVK2-pT8_C3MilRDZj7Ni_nDHPgue6iks5sD2x-gaJpZM4Jxsey>.
|
It appears that the app services environment doesn't support signalling other processes. I thought that the kudu console handled ctrl+c and the like, but it doesn't: projectkudu/kudu#864 |
Moving this issue to aspnet/AspNetCoreModule#115. The summary is that our signaling mechanics are blocked in azure and we need to design some new ones for 2.0. |
We've noticed the ApplicationStopped event doesn't seem to get called if you stop or restart a dotnetcore Azure web app (full fat .net 4.6 framework).
Stopping our site in IIS Express doesn't work either (using the system tray stop site option) although the Kestrel server does appear to work (assuming you stop it using ctrl+c).
We did come across the ApplicationStopping issue (#812) which is why we are using ApplicationStopped but it doesn't seem to work. Would I be correct in assuming that selecting stop or restart from the Azure portal is not considered a graceful shutdown?
The text was updated successfully, but these errors were encountered: