resque icon indicating copy to clipboard operation
resque copied to clipboard

Make the signal for child termination configurable

Open fxn opened this issue 1 year ago • 1 comments

Resque sends SIGTERM to signal the child process it should terminate, but this conflicts with Heroku, which sends SIGTERM to all processes when shutting down dynos. That is, your child receives SIGTERM from Heroku right away and RESQUE_PRE_SHUTDOWN_TIMEOUT is not honored.

The gem resque-heroku-signals addresses this by redefining Resque::Worker#unregister_signal_handlers in a way that makes the SIGTERM signal handler ignore the first occurrence, and raise Resque::TermException on the second one.

However, this solution is partial, really, because Heroku documents it may send you multiple SIGTERMs, and I have confirmed it occasionally does. Therefore, you cannot assume the 2nd signal comes from the worker.

A clean way to solve this would be to tell Resque to use a different signal. I suspect this might be the intention with the existing

attr_accessor :term_child_signal

which seems to be unused as of this writing.

fxn avatar Apr 19 '23 06:04 fxn