regula icon indicating copy to clipboard operation
regula copied to clipboard

Graceful shutdown doesn't work properly because of the use of context

Open asdine opened this issue 5 years ago • 1 comments

When the Server is instantiated, we create a cancelable context and pass the cancel function to the RegisterOnShutdown method, then this context is used in every HTTP request. Which means that when Regula receives a SIGINT signal:

  • It asks the server to Shutdown
  • The server cancels the context (it runs the function registered in RegisterOnShutdown)
  • Every request using the context is canceled, which returns 500s to the clients

This behaviour is useful for long-running watch requests: the server can't wait for 30 seconds before closing so the goal is to cancel them. But we shouldn't cancel short operations like list, eval and put, the server should let the current operations finish and simply stop receiving new requests. We should use another context for those.

asdine avatar Oct 17 '18 08:10 asdine

Good catch 👍

jhchabran avatar Oct 17 '18 08:10 jhchabran