Method: Resque::Worker#unregister_worker
- Defined in:
- lib/resque/worker.rb
#unregister_worker(exception = nil) ⇒ Object
Unregisters ourself as a worker. Useful when shutting down.
720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 |
# File 'lib/resque/worker.rb', line 720 def unregister_worker(exception = nil) # If we're still processing a job, make sure it gets logged as a # failure. if (hash = processing) && !hash.empty? job = Job.new(hash['queue'], hash['payload']) # Ensure the proper worker is attached to this job, even if # it's not the precise instance that died. job.worker = self begin job.fail(exception || DirtyExit.new("Job still being processed")) rescue RuntimeError => e log_with_severity :error, e. end end kill_background_threads data_store.unregister_worker(self) do |**opts| Stat.clear("processed:#{self}", **opts) Stat.clear("failed:#{self}", **opts) end rescue Exception => exception_while_unregistering = exception_while_unregistering. if exception += "\nOriginal Exception (#{exception.class}): #{exception.message}" += "\n #{exception.backtrace.join(" \n")}" if exception.backtrace end fail(exception_while_unregistering.class, , exception_while_unregistering.backtrace) end |