From 5bc1086ef39a5a1f4c285b69284f67c3b5032ad7 Mon Sep 17 00:00:00 2001 From: John Andrews + Andrew Grieser Date: Tue, 19 Jul 2011 14:58:31 -0400 Subject: [PATCH] Work around JRuby shell escaping bug, fix finding worker pids on JRuby --- lib/resque/worker.rb | 4 ++-- test/worker_test.rb | 5 +++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/resque/worker.rb b/lib/resque/worker.rb index f1ddf1f00..cbc0714db 100644 --- a/lib/resque/worker.rb +++ b/lib/resque/worker.rb @@ -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 @@ -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}" diff --git a/test/worker_test.rb b/test/worker_test.rb index 8200df9c2..a884ae5ff 100644 --- a/test/worker_test.rb +++ b/test/worker_test.rb @@ -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]