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)
142
142
rescue SystemCallError
143
143
nil
144
144
end
145
+ job . fail ( DirtyExit . new ( $?. to_s ) ) if $?. signaled?
145
146
else
146
147
unregister_signal_handlers if will_fork?
147
148
procline "Processing #{ job . queue } since #{ Time . now . to_i } "
148
149
reconnect
149
150
perform ( job , &block )
150
- exit! if will_fork?
151
+ exit! ( true ) if will_fork?
151
152
end
152
153
153
154
done_working
Original file line number Diff line number Diff line change @@ -689,5 +689,28 @@ def self.perform( run_time, rescue_time=nil )
689
689
end
690
690
end
691
691
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
692
715
end
693
716
end
You can’t perform that action at this time.
0 commit comments