Skip to content

Commit fd1d9ae

Browse files
wuputahhone
authored andcommitted
send term first, then kill
1 parent 82ea71c commit fd1d9ae

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

lib/resque/worker.rb

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,17 @@ def shutdown?
299299
@shutdown
300300
end
301301

302-
# Kills the forked child immediately, without remorse. The job it
302+
# Kills the forked child immediately with minimal remorse. The job it
303303
# is processing will not be completed.
304304
def kill_child
305305
if @child
306306
log! "Killing child at #{@child}"
307307
if system("ps -o pid,state -p #{@child}")
308+
Process.kill("TERM", @child) rescue nil
309+
10.times do
310+
return unless system("ps -o pid,state -p #{@child}")
311+
sleep(0.1)
312+
end
308313
Process.kill("KILL", @child) rescue nil
309314
else
310315
log! "Child #{@child} not found, restarting."

0 commit comments

Comments
 (0)