Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QUESTION: Is graceful shutdown possible? #654

Closed
stap123 opened this issue Oct 3, 2021 · 5 comments
Closed

QUESTION: Is graceful shutdown possible? #654

stap123 opened this issue Oct 3, 2021 · 5 comments

Comments

@stap123
Copy link

stap123 commented Oct 3, 2021

Is it possible to know when a function is about to be terminated by the runtime to perform a graceful shutdown?

It would be good to be able to get a notification of when this about to happen and do some logging at a bare minimum.

Thank you 😃

@ssa3512
Copy link

ssa3512 commented Oct 8, 2021

Based on this comment you should be able to inject IHostApplicationLifetime into your function class and use the ApplicationStopping cancellation token to detect shutdown.

@fabiocav
Copy link
Member

Yes, you can use the application lifetime to get notified, but we're actively working on enhancements to enable a behavior that puts the app into a drain mode.

@nzthiago will be posting updates on this as we reach preview/GA states.

@stap123
Copy link
Author

stap123 commented Oct 12, 2021

@fabiocav Is there somewhere we can follow to see what's currently being worked on somewhere specifically these updates will be published?

@nzthiago
Copy link
Member

@fabiocav Is there somewhere we can follow to see what's currently being worked on somewhere specifically these updates will be published?

I just created this entry on the host repo that you can follow for updates Azure/azure-functions-host#7772

It's a mostly internal implementation but we'll make sure to update the CancellationToken documentation with an example as well.

@ghost ghost locked as resolved and limited conversation to collaborators Nov 13, 2021
@nzthiago
Copy link
Member

Please note that at the moment the .NET isolated (i.e., out of process worker) doesn't have Cancellation Token support. To be surfaced to the .NET isolated worker this depends on a host update related to this feature Azure/azure-functions-host#7785, and requires further design decisions and prioritization, so for now the documentation here is up to date. Note that even though the cancellation token isn't flowing into the out of proc function, a graceful period should still be given to your function as per this work in Consumption and Premium plans.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants