File tree Expand file tree Collapse file tree 2 files changed +25
-1
lines changed
Expand file tree Collapse file tree 2 files changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -142,12 +142,13 @@ def work(interval = 5.0, &block)
142142 rescue SystemCallError
143143 nil
144144 end
145+ job . fail ( DirtyExit . new ( $?. to_s ) ) if $?. signaled?
145146 else
146147 unregister_signal_handlers if will_fork?
147148 procline "Processing #{ job . queue } since #{ Time . now . to_i } "
148149 reconnect
149150 perform ( job , &block )
150- exit! if will_fork?
151+ exit! ( true ) if will_fork?
151152 end
152153
153154 done_working
Original file line number Diff line number Diff line change @@ -689,5 +689,28 @@ def self.perform( run_time, rescue_time=nil )
689689 end
690690 end
691691 end
692+
693+ class SuicidalJob
694+ @queue = :jobs
695+
696+ def self . perform
697+ Process . kill ( 'KILL' , Process . pid )
698+ end
699+
700+ def self . on_failure_store_exception ( exc , *args )
701+ @@failure_exception = exc
702+ end
703+ end
704+
705+ it "will notify failure hooks when a job is killed by a signal" do
706+ begin
707+ $TESTING = false
708+ Resque . enqueue ( SuicidalJob )
709+ @worker . work ( 0 )
710+ assert_equal Resque ::DirtyExit , SuicidalJob . send ( :class_variable_get , :@@failure_exception ) . class
711+ ensure
712+ $TESTING = true
713+ end
714+ end
692715 end
693716end
You can’t perform that action at this time.
0 commit comments