gajus / lightship

Abstracts readiness, liveness and startup checks and graceful shutdown of Node.js services running in Kubernetes.
Other
518 stars 32 forks source link

Clarify best practices in readme #33

Closed rexxars closed 3 years ago

rexxars commented 3 years ago

Hi, and thanks for creating this great library!

The readme has this under the "best practices" section:

It is important that you do not cease to handle new incoming requests immediately after receiving the shutdown signal. This is because there is a high probability of the SIGTERM signal being sent well before the iptables rules are updated on all nodes. The result is that the pod may still receive client requests after it has received the termination signal. If the app stops accepting connections immediately, it causes clients to receive "connection refused" types of errors.

I find this a little disconnected from the rest of the readme: is this at all related to the options you set on the lightship instance, eg shutdownDelay or similar? Should you manually set a timer inside of a registerShutdownHandler before calling .close() on an HTTP server? I think some more context would be very beneficial to users :)

gajus commented 3 years ago

I believe this particular notice was added before shutdownDelay existed.

shutdownDelay defaults to 5 seconds, which is sufficient. You don't need to do anything in addition to that.