Tuesday 27 December 2016

Gracefully terminating node processes on SIGTERM/SIGKILL

Are there some good resources or examples that show how to gracefully terminate node processes when you do 'ctrl c' in the terminal to end the process?In the example I'm thinking about, there are queue worker processes that get a bunch of items from the queue and process them. When it successfully processes those items, it gets the next bunch of items from the queue and processes those. And it does all this in a neverending loop.Since I'm not handling this gracefully, when I terminate the node process, it kills the process right away and leaves an inconsistent state. I've never worked with gracefully terminating processes or handling SIGTERM/SIGKILL before, so any explanation or tutorials would really help.And how would you handle SIGTERM and SIGKILL differently? Or would they both have identical behavior?

Submitted December 27, 2016 at 01:49PM by nowboarding

No comments:

Post a Comment