gajus/lightship

lightship with express + http-terminator.

Opened this issue · 1 comments

I have an express app that is going to be deployed into a k8s stack and was investigating the use of lightship for readiness checks.

In the lightship readme is the recommendation "Add a delay before stop handling incoming requests"…

Instead of this, would it be reasonable to use http-terminator inside a lightship shutdown handler? Or is that redundant?

Hey, we are currently doing the exact same thing (graceful shutdown of express app in k8s) so I don't know if it's perfect but I can share what I figured out :

  1. regarding the delay, the doc seems redundant because it is taken care of if you properly set shutDownDelay in the options (your shutdown handler gets called after that delay),
  2. we have just added http-terminator as well, because without it your express server is likely to hang due to persistent requests (websockets, keep-alive...),
  3. personally I don't see any link between these two because the first one avoids new incoming connection before you stop handling them, the second one ensures existing connections are properly closed before the process exits.

We were already using lightship, but for simple workers picking up jobs (no incoming requests), so any corrections are welcome :)