diff --git a/HISTORY.md b/HISTORY.md index d8def79e9..3b847f833 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,3 +1,21 @@ +## 1.18.2 (2011-08-19) + +* Fix RAILS_ROOT deprecation warning + +## 1.18.1 (2011-08-19) + +* Bugfix: Use RAILS_ROOT in preload task + +## 1.18.0 (2011-08-18) + +* Added before_enqueue hook. +* Resque workers now preload files under app/ in Rails +* Switch to MultiJSON +* Bugfix: Finding worker pids on Solaris +* Web UI: Fix NaN days ago for worker screens +* Web UI: Add Cache-Control header to prevent proxy caching +* Web UI: Update Resque.redis_id so it can be used in a distributed ring. + ## 1.17.1 (2011-05-27) * Reverted `exit` change. Back to `exit!`. diff --git a/lib/resque/tasks.rb b/lib/resque/tasks.rb index dfa8c92a1..ca1851ea9 100644 --- a/lib/resque/tasks.rb +++ b/lib/resque/tasks.rb @@ -5,7 +5,7 @@ task :setup desc "Start a Resque worker" - task :work => :setup do + task :work => [ :preload, :setup ] do require 'resque' queues = (ENV['QUEUES'] || ENV['QUEUE']).to_s.split(',') @@ -39,4 +39,13 @@ threads.each { |thread| thread.join } end + + # Preload app files if this is Rails + task :preload do + if defined? Rails + Dir["#{Rails.root}/app/**/*.rb"].each do |file| + require file + end + end + end end diff --git a/lib/resque/version.rb b/lib/resque/version.rb index c17b0ebdb..304f6e4bd 100644 --- a/lib/resque/version.rb +++ b/lib/resque/version.rb @@ -1,3 +1,3 @@ module Resque - Version = VERSION = '1.17.1' + Version = VERSION = '1.18.2' end diff --git a/lib/resque/worker.rb b/lib/resque/worker.rb index fad6b174f..d86fe3562 100644 --- a/lib/resque/worker.rb +++ b/lib/resque/worker.rb @@ -312,7 +312,7 @@ def kill_child def paused? @paused end - + # Stop processing jobs after the current one has completed (if we're # currently running one). def pause_processing @@ -483,14 +483,40 @@ def pid @pid ||= to_s.split(":")[1].to_i end - # Returns an array of string pids of all the other workers on this + # Returns an Array of string pids of all the other workers on this # machine. Useful when pruning dead workers on startup. def worker_pids + if RUBY_PLATFORM =~ /solaris/ + solaris_worker_pids + else + linux_worker_pids + end + end + + # Find Resque worker pids on Linux and OS X. + # + # Returns an Array of string pids of all the other workers on this + # machine. Useful when pruning dead workers on startup. + def linux_worker_pids `ps -A -o pid,command | grep [r]esque | grep -v "resque-web"`.split("\n").map do |line| line.split(' ')[0] end end + # Find Resque worker pids on Solaris. + # + # Returns an Array of string pids of all the other workers on this + # machine. Useful when pruning dead workers on startup. + def solaris_worker_pids + `ps -A -o pid,comm | grep [r]uby | grep -v "resque-web"`.split("\n").map do |line| + real_pid = line.split(' ')[0] + pargs_command = `pargs -a #{real_pid} 2>/dev/null | grep [r]esque | grep -v "resque-web"` + if pargs_command.split(':')[1] == " resque-#{Resque::Version}" + real_pid + end + end.compact + end + # Given a string, sets the procline ($0) and logs. # Procline is always in the format of: # resque-VERSION: STRING