lib/resque/worker.rb in resque-1.1.0 vs lib/resque/worker.rb in resque-1.2.0
- old
+ new
@@ -243,11 +243,16 @@
# Kills the forked child immediately, without remorse. The job it
# is processing will not be completed.
def kill_child
if @child
log! "Killing child at #{@child}"
- Process.kill("KILL", @child) rescue nil
+ if system("ps -ho pid,state -p #{@child}")
+ Process.kill("KILL", @child) rescue nil
+ else
+ log! "Child #{@child} not found, restarting."
+ shutdown
+ end
end
end
# Looks for any workers which should be running on this server
# and, if they're not, removes them from Redis.
@@ -381,10 +386,10 @@
end
# Returns an array of string pids of all the other workers on this
# machine. Useful when pruning dead workers on startup.
def worker_pids
- `ps -e -o pid,command | grep [r]esque`.split("\n").map do |line|
+ `ps -A -o pid,command | grep [r]esque`.split("\n").map do |line|
line.split(' ')[0]
end
end
# Log a message to STDOUT if we are verbose or very_verbose.