Skip to content

Commit

Permalink
Work around JRuby shell escaping bug, fix finding worker pids on JRuby
Browse files Browse the repository at this point in the history
  • Loading branch information
John Andrews + Andrew Grieser authored and defunkt committed Sep 22, 2011
1 parent 8b15ac3 commit 5bc1086
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/resque/worker.rb
Expand Up @@ -498,7 +498,7 @@ def worker_pids
# Returns an Array of string pids of all the other workers on this
# machine. Useful when pruning dead workers on startup.
def linux_worker_pids
`ps -A -o pid,command | grep [r]esque | grep -v "resque-web"`.split("\n").map do |line|
`ps -A -o pid,command | grep "[r]esque" | grep -v "resque-web"`.split("\n").map do |line|
line.split(' ')[0]
end
end
Expand All @@ -508,7 +508,7 @@ def linux_worker_pids
# Returns an Array of string pids of all the other workers on this
# machine. Useful when pruning dead workers on startup.
def solaris_worker_pids
`ps -A -o pid,comm | grep [r]uby | grep -v "resque-web"`.split("\n").map do |line|
`ps -A -o pid,comm | grep "[r]uby" | grep -v "resque-web"`.split("\n").map do |line|
real_pid = line.split(' ')[0]
pargs_command = `pargs -a #{real_pid} 2>/dev/null | grep [r]esque | grep -v "resque-web"`
if pargs_command.split(':')[1] == " resque-#{Resque::Version}"
Expand Down
5 changes: 5 additions & 0 deletions test/worker_test.rb
Expand Up @@ -285,6 +285,11 @@ def self.exception
end
end

test "worker_pids returns pids" do
known_workers = @worker.worker_pids
assert !known_workers.empty?
end

test "Processed jobs count" do
@worker.work(0)
assert_equal 1, Resque.info[:processed]
Expand Down

0 comments on commit 5bc1086

Please sign in to comment.