File tree Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Expand file tree Collapse file tree 2 files changed +12
-0
lines changed Original file line number Diff line number Diff line change @@ -4,4 +4,7 @@ class NoQueueError < RuntimeError; end
4
4
5
5
# Raised when trying to create a job without a class
6
6
class NoClassError < RuntimeError ; end
7
+
8
+ # Raised when a worker was killed while processing a job.
9
+ class DirtyExit < RuntimeError ; end
7
10
end
Original file line number Diff line number Diff line change @@ -326,6 +326,15 @@ def run_hook(name, *args)
326
326
327
327
# Unregisters ourself as a worker. Useful when shutting down.
328
328
def unregister_worker
329
+ # If we're still processing a job, make sure it gets logged as a
330
+ # failure.
331
+ if job
332
+ # Ensure the proper worker is attached to this job, even if
333
+ # it's not the precise instance that died.
334
+ job . worker = self
335
+ job . fail ( DirtyExit . new )
336
+ end
337
+
329
338
redis . srem ( :workers , self )
330
339
redis . del ( "worker:#{ self } " )
331
340
redis . del ( "worker:#{ self } :started" )
You can’t perform that action at this time.
0 commit comments