Skip to content

Commit

Permalink
Fix issue with finding worker pids on jruby
Browse files Browse the repository at this point in the history
- Old pattern returned empty array of worker pids on jruby
  • Loading branch information
John Andrews + Andrew Grieser authored and defunkt committed Jul 19, 2011
1 parent 3bc9244 commit 9b4b900
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 1 addition & 1 deletion lib/resque/worker.rb
Expand Up @@ -476,7 +476,7 @@ def pid
# 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 -A -o pid,command | grep [r]esque | grep -v "resque-web"`.split("\n").map do |line|
`ps -A -o pid,command | grep resque | grep -v "resque-web"`.split("\n").map do |line|
line.split(' ')[0]
end
end
Expand Down
5 changes: 5 additions & 0 deletions test/worker_test.rb
Expand Up @@ -267,6 +267,11 @@
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 9b4b900

Please sign in to comment.