graceful shutdown?
Any recommended ways to make sure servers are shut down gracefully? Are there explicit expectations about how requests are handled when the process receives sigint or sigterm?
4 Replies
genetic-orange•3mo ago
generally you want to stop accepting new requests, finish any requests that are in flight, then shut down. this package does this for several popular servers: https://www.npmjs.com/package/http-graceful-shutdown
npm
http-graceful-shutdown
gracefully shuts downs http server. Latest version: 3.1.14, last published: 5 months ago. Start using http-graceful-shutdown in your project by running
npm i http-graceful-shutdown
. There are 71 other projects in the npm registry using http-graceful-shutdown.genetic-orange•3mo ago
not sure if nitro / h3 have similar behavior
genetic-orange•3mo ago
looks like nitro has a
close
hook you could use: https://github.com/nuxt/nuxt/issues/19888#issuecomment-1542111353GitHub
Process Shutdown Hooks not Triggered in Nitro Plugins · Issue #198...
Environment Nuxi 3.3.1 RootDir: /home/projects/github-yqqs2f Nuxt project info: Operating System: Linux Node Version: v16.14.2 Nuxt Version: 3.3.1 Nitro Version: 2.3.1 Package Manager: npm@7.17.0 B...
deep-jadeOP•2mo ago
do you have examples of hooking into nitro with Start? i wasn't able to immediately figure it out and i didnt see it in the docs
Bump on this question! Still not sure