backburner icon indicating copy to clipboard operation
backburner copied to clipboard

Trigger some code when worker times out or is killed

Open geoffroymontel opened this issue 9 years ago • 3 comments

Hi there

I'm using backburner:threads_on_fork:work in production and I'd like some code on my workers to be run when the worker times out or is killed.

I enclosed my worker code in a begin/rescue

    begin
      # do time consuming thing
    rescue => e
      Rails.logger.error("There was an error = #{e} ")
      myModel.update_attributes(state: "error")
      raise e
    end

but it seems the code in rescue is never called.

Any hint ?

Thanks in advance

geoffroy

geoffroymontel avatar Mar 16 '15 12:03 geoffroymontel

@geoffroymontel Once 1.1 goes out (today?) you'll be able to add hooks for on_retry and on_bury. Will those be sufficient?

contentfree avatar Sep 14 '15 20:09 contentfree

@contentfree I don't think these hooks will be triggered when the worker is killed but I will try the new version and keep you updated. Thanks !

geoffroymontel avatar Sep 15 '15 06:09 geoffroymontel

Possibly. You mean killed killed, not just buried. They should work for timeouts though…

contentfree avatar Sep 15 '15 07:09 contentfree