@@ -302,7 +302,7 @@ def kill_child
302
302
def paused?
303
303
@paused
304
304
end
305
-
305
+
306
306
# Stop processing jobs after the current one has completed (if we're
307
307
# currently running one).
308
308
def pause_processing
@@ -473,14 +473,40 @@ def pid
473
473
@pid ||= to_s . split ( ":" ) [ 1 ] . to_i
474
474
end
475
475
476
- # Returns an array of string pids of all the other workers on this
476
+ # Returns an Array of string pids of all the other workers on this
477
477
# machine. Useful when pruning dead workers on startup.
478
478
def worker_pids
479
+ if RUBY_PLATFORM =~ /solaris/
480
+ solaris_worker_pids
481
+ else
482
+ linux_worker_pids
483
+ end
484
+ end
485
+
486
+ # Find Resque worker pids on Linux and OS X.
487
+ #
488
+ # Returns an Array of string pids of all the other workers on this
489
+ # machine. Useful when pruning dead workers on startup.
490
+ def linux_worker_pids
479
491
`ps -A -o pid,command | grep [r]esque | grep -v "resque-web"` . split ( "\n " ) . map do |line |
480
492
line . split ( ' ' ) [ 0 ]
481
493
end
482
494
end
483
495
496
+ # Find Resque worker pids on Solaris.
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 solaris_worker_pids
501
+ `ps -A -o pid,comm | grep ruby | grep -v grep | grep -v "resque-web"` . split ( "\n " ) . map do |line |
502
+ real_pid = line . split ( ' ' ) [ 0 ]
503
+ pargs_command = `pargs -a #{ real_pid } 2>/dev/null | grep [r]esque | grep -v "resque-web"`
504
+ if pargs_command . split ( ':' ) [ 1 ] == " resque-#{ Resque ::Version } "
505
+ real_pid
506
+ end
507
+ end . compact
508
+ end
509
+
484
510
# Given a string, sets the procline ($0) and logs.
485
511
# Procline is always in the format of:
486
512
# resque-VERSION: STRING
0 commit comments