@@ -312,7 +312,7 @@ def kill_child
312312 def paused?
313313 @paused
314314 end
315-
315+
316316 # Stop processing jobs after the current one has completed (if we're
317317 # currently running one).
318318 def pause_processing
@@ -483,14 +483,40 @@ def pid
483483 @pid ||= to_s . split ( ":" ) [ 1 ] . to_i
484484 end
485485
486- # Returns an array of string pids of all the other workers on this
486+ # Returns an Array of string pids of all the other workers on this
487487 # machine. Useful when pruning dead workers on startup.
488488 def worker_pids
489+ if RUBY_PLATFORM =~ /solaris/
490+ solaris_worker_pids
491+ else
492+ linux_worker_pids
493+ end
494+ end
495+
496+ # Find Resque worker pids on Linux and OS X.
497+ #
498+ # Returns an Array of string pids of all the other workers on this
499+ # machine. Useful when pruning dead workers on startup.
500+ def linux_worker_pids
489501 `ps -A -o pid,command | grep [r]esque | grep -v "resque-web"` . split ( "\n " ) . map do |line |
490502 line . split ( ' ' ) [ 0 ]
491503 end
492504 end
493505
506+ # Find Resque worker pids on Solaris.
507+ #
508+ # Returns an Array of string pids of all the other workers on this
509+ # machine. Useful when pruning dead workers on startup.
510+ def solaris_worker_pids
511+ `ps -A -o pid,comm | grep [r]uby | grep -v "resque-web"` . split ( "\n " ) . map do |line |
512+ real_pid = line . split ( ' ' ) [ 0 ]
513+ pargs_command = `pargs -a #{ real_pid } 2>/dev/null | grep [r]esque | grep -v "resque-web"`
514+ if pargs_command . split ( ':' ) [ 1 ] == " resque-#{ Resque ::Version } "
515+ real_pid
516+ end
517+ end . compact
518+ end
519+
494520 # Given a string, sets the procline ($0) and logs.
495521 # Procline is always in the format of:
496522 # resque-VERSION: STRING
0 commit comments