Skip to content

Commit 6caf6b6

Browse files
author
mpd
committed
Merge branch 'defunkt' into distributed
2 parents 65780fc + f0f1694 commit 6caf6b6

File tree

4 files changed

+57
-4
lines changed

4 files changed

+57
-4
lines changed

HISTORY.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,21 @@
1+
## 1.18.2 (2011-08-19)
2+
3+
* Fix RAILS_ROOT deprecation warning
4+
5+
## 1.18.1 (2011-08-19)
6+
7+
* Bugfix: Use RAILS_ROOT in preload task
8+
9+
## 1.18.0 (2011-08-18)
10+
11+
* Added before_enqueue hook.
12+
* Resque workers now preload files under app/ in Rails
13+
* Switch to MultiJSON
14+
* Bugfix: Finding worker pids on Solaris
15+
* Web UI: Fix NaN days ago for worker screens
16+
* Web UI: Add Cache-Control header to prevent proxy caching
17+
* Web UI: Update Resque.redis_id so it can be used in a distributed ring.
18+
119
## 1.17.1 (2011-05-27)
220

321
* Reverted `exit` change. Back to `exit!`.

lib/resque/tasks.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
task :setup
66

77
desc "Start a Resque worker"
8-
task :work => :setup do
8+
task :work => [ :preload, :setup ] do
99
require 'resque'
1010

1111
queues = (ENV['QUEUES'] || ENV['QUEUE']).to_s.split(',')
@@ -39,4 +39,13 @@
3939

4040
threads.each { |thread| thread.join }
4141
end
42+
43+
# Preload app files if this is Rails
44+
task :preload do
45+
if defined? Rails
46+
Dir["#{Rails.root}/app/**/*.rb"].each do |file|
47+
require file
48+
end
49+
end
50+
end
4251
end

lib/resque/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Resque
2-
Version = VERSION = '1.17.1'
2+
Version = VERSION = '1.18.2'
33
end

lib/resque/worker.rb

Lines changed: 28 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)