Skip to content

Commit 5bc1086

Browse files
John Andrews + Andrew Grieserdefunkt
authored andcommitted
Work around JRuby shell escaping bug, fix finding worker pids on JRuby
1 parent 8b15ac3 commit 5bc1086

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

lib/resque/worker.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -498,7 +498,7 @@ def worker_pids
498498
# Returns an Array of string pids of all the other workers on this
499499
# machine. Useful when pruning dead workers on startup.
500500
def linux_worker_pids
501-
`ps -A -o pid,command | grep [r]esque | grep -v "resque-web"`.split("\n").map do |line|
501+
`ps -A -o pid,command | grep "[r]esque" | grep -v "resque-web"`.split("\n").map do |line|
502502
line.split(' ')[0]
503503
end
504504
end
@@ -508,7 +508,7 @@ def linux_worker_pids
508508
# Returns an Array of string pids of all the other workers on this
509509
# machine. Useful when pruning dead workers on startup.
510510
def solaris_worker_pids
511-
`ps -A -o pid,comm | grep [r]uby | grep -v "resque-web"`.split("\n").map do |line|
511+
`ps -A -o pid,comm | grep "[r]uby" | grep -v "resque-web"`.split("\n").map do |line|
512512
real_pid = line.split(' ')[0]
513513
pargs_command = `pargs -a #{real_pid} 2>/dev/null | grep [r]esque | grep -v "resque-web"`
514514
if pargs_command.split(':')[1] == " resque-#{Resque::Version}"

test/worker_test.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,11 @@ def self.exception
285285
end
286286
end
287287

288+
test "worker_pids returns pids" do
289+
known_workers = @worker.worker_pids
290+
assert !known_workers.empty?
291+
end
292+
288293
test "Processed jobs count" do
289294
@worker.work(0)
290295
assert_equal 1, Resque.info[:processed]

0 commit comments

Comments
 (0)