Skip to content

Commit a3b675a

Browse files
pmortonsteveklabnik
authored andcommitted
Worker PID detection for windows
1 parent 7dea194 commit a3b675a

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

lib/resque/worker.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -529,11 +529,21 @@ def pid
529529
def worker_pids
530530
if RUBY_PLATFORM =~ /solaris/
531531
solaris_worker_pids
532+
elsif RUBY_PLATFORM =~ /mingw32/
533+
windows_worker_pids
532534
else
533535
linux_worker_pids
534536
end
535537
end
536538

539+
# Find Resque worker pids on Windows.
540+
#
541+
# Returns an Array of string pids of all the other workers on this
542+
# machine. Useful when pruning dead workers on startup.
543+
def windows_worker_pids
544+
`tasklist /FI "IMAGENAME eq ruby.exe" /FO list`.split("\n").select { |line| line =~ /^PID:/}.collect{ |line| line.gsub /PID:\s+/, '' }
545+
end
546+
537547
# Find Resque worker pids on Linux and OS X.
538548
#
539549
def linux_worker_pids

0 commit comments

Comments
 (0)