OpenFunction / functions-framework

functions-framework for multi-runtime, multi-type functions, and multi-language support
10 stars 6 forks source link

Gracefully shutdown function on SIGINT & SIGTERM #22

Open wrongerror opened 2 years ago

wrongerror commented 2 years ago

When the function rollout or scaledown, we need the function to be gracefully shutdown to avoid losing the request or event.

benjaminhuo commented 2 years ago

@rajibmitra , are you interested in implementing the graceful shutdown feature for functions-framework-go? https://github.com/OpenFunction/functions-framework-go :

Relevant source code: https://github.com/OpenFunction/functions-framework-go https://github.com/OpenFunction/builder/blob/main/cmd/go/of_functions_framework/template.go#L17

benjaminhuo commented 2 years ago

See also: https://github.com/gorilla/mux#graceful-shutdown : go functions framework is using gorilla now https://rafallorenz.com/go/handle-signals-to-graceful-shutdown-http-server/ https://clavinjune.dev/en/blogs/golang-http-server-graceful-shutdown/ https://www.rudderstack.com/blog/implementing-graceful-shutdown-in-go/ https://leileiluoluo.com/posts/golang-shutdown-server-gracefully.html

benjaminhuo commented 2 years ago

@zhbinary you can implement this for https://github.com/OpenFunction/functions-framework-go first