resque-mongo 1.8.1 → 1.9.8.1

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY.md CHANGED
@@ -1,3 +1,73 @@
1
+ ## 1.9.8 (2010-07-20)
2
+
3
+ * Bugfix: Worker.all should never return nil
4
+ * monit example: Fixed Syntax Error and adding environment to the rake task
5
+ * redis rake task: Fixed typo in copy command
6
+
7
+ ## 1.9.7 (2010-07-09)
8
+
9
+ * Improved memory usage in Job.destroy
10
+ * redis-namespace 0.7.0 now required
11
+ * Bugfix: Reverted $0 changes
12
+ * Web Bugfix: Payload-less failures in the web ui work
13
+
14
+ ## 1.9.6 (2010-06-22)
15
+
16
+ * Bugfix: Rakefile logging works the same as all the other logging
17
+
18
+ ## 1.9.5 (2010-06-16)
19
+
20
+ * Web Bugfix: Display the configured namespace on the stats page
21
+ * Revert Bugfix: Make ps -o more cross platform friendly
22
+
23
+ ## 1.9.4 (2010-06-14)
24
+
25
+ * Bugfix: Multiple failure backend gets exception information when created
26
+
27
+ ## 1.9.3 (2010-06-14)
28
+
29
+ * Bugfix: Resque#queues always returns an array
30
+
31
+ ## 1.9.2 (2010-06-13)
32
+
33
+ * Bugfix: Worker.all returning nil fix
34
+ * Bugfix: Make ps -o more cross platform friendly
35
+
36
+ ## 1.9.1 (2010-06-04)
37
+
38
+ * Less strict JSON dependency
39
+ * Included HISTORY.md in gem
40
+
41
+ ## 1.9.0 (2010-06-04)
42
+
43
+ * Redis 2 support
44
+ * Depend on redis-namespace 0.5.0
45
+ * Added Resque::VERSION constant (alias of Resque::Version)
46
+ * Bugfix: Specify JSON dependency
47
+ * Bugfix: Hoptoad plugin now works on 1.9
48
+
49
+ ## 1.8.5 (2010-05-18)
50
+
51
+ * Bugfix: Be more liberal in which Redis clients we accept.
52
+
53
+ ## 1.8.4 (2010-05-18)
54
+
55
+ * Try to resolve redis-namespace dependency issue
56
+
57
+ ## 1.8.3 (2010-05-17)
58
+
59
+ * Depend on redis-rb ~> 1.0.7
60
+
61
+ ## 1.8.2 (2010-05-03)
62
+
63
+ * Bugfix: Include "tasks/" dir in RubyGem
64
+
65
+ ## 1.8.1 (2010-04-29)
66
+
67
+ * Bugfix: Multiple failure backend did not support requeue-ing failed jobs
68
+ * Bugfix: Fix /failed when error has no backtrace
69
+ * Bugfix: Add `Redis::DistRedis` as a valid client
70
+
1
71
  ## 1.8.0 (2010-04-07)
2
72
 
3
73
  * Jobs that never complete due to killed worker are now failed.
@@ -11,7 +11,12 @@ findAndModify that is only supported by 0.20+ version ofthe ruby mongo driver.
11
11
 
12
12
  Also, check your mongo version: 1.3.0 or higher
13
13
 
14
- [fnr]: http://www.mongodb.org/display/DOCS/findandmodify+Command
14
+ [fnr]: http://www.mongodb.org/display/DOCS/findandmodify+Command
15
+
16
+ gem install resque-mongo
17
+ # Rails integration, config/environment.rb
18
+ config.gem 'resque-mongo', :lib => 'resque'
19
+
15
20
 
16
21
  Resque
17
22
  ======
@@ -677,7 +682,7 @@ For a list of available plugins see
677
682
 
678
683
  If you'd like to write your own plugin, or want to customize Resque
679
684
  using hooks (such as `Resque.after_fork`), see
680
- [docs/HOOKS.md](http://github.com/defunkt/resque/blob/master/HOOKS.md).
685
+ [docs/HOOKS.md](http://github.com/defunkt/resque/blob/master/docs/HOOKS.md).
681
686
 
682
687
 
683
688
  Namespaces
data/Rakefile CHANGED
@@ -3,6 +3,15 @@ load 'tasks/redis.rake'
3
3
  $LOAD_PATH.unshift 'lib'
4
4
  require 'resque/tasks'
5
5
 
6
+ def command?(command)
7
+ system("type #{command} > /dev/null 2>&1")
8
+ end
9
+
10
+
11
+ #
12
+ # Tests
13
+ #
14
+
6
15
  task :default => :test
7
16
 
8
17
  desc "Run tests"
@@ -20,46 +29,32 @@ task :kick do
20
29
  exec "kicker -e rake lib test"
21
30
  end
22
31
 
23
- task :install => [ 'redis:install', 'dtach:install' ]
24
32
 
25
- desc "Build a gem"
26
- task :gem => [ :test, :gemspec, :build ]
33
+ #
34
+ # Install
35
+ #
27
36
 
28
- begin
29
- require 'jeweler'
30
- require 'resque/version'
37
+ task :install => [ 'redis:install', 'dtach:install' ]
31
38
 
32
- Jeweler::Tasks.new do |gemspec|
33
- gemspec.name = "resque-mongo"
34
- gemspec.summary = ""
35
- gemspec.description = ""
36
- gemspec.email = "yatiohi@ideopolis.gr"
37
- gemspec.homepage = "http://github.com/ctrochalakis/resque-mongo"
38
- gemspec.authors = ["Christos Trochalakis"]
39
- gemspec.version = Resque::Version
40
39
 
41
- gemspec.add_dependency "mongo", ">=0.20"
42
- gemspec.add_dependency "vegas", ">=0.1.2"
43
- gemspec.add_dependency "sinatra", ">=0.9.2"
44
- gemspec.add_development_dependency "jeweler"
45
- end
46
- rescue LoadError
47
- puts "Jeweler not available. Install it with: "
48
- puts "gem install jeweler"
49
- end
40
+ #
41
+ # Documentation
42
+ #
50
43
 
51
44
  begin
52
45
  require 'sdoc_helpers'
53
46
  rescue LoadError
54
- puts "sdoc support not enabled. Please gem install sdoc-helpers."
55
47
  end
56
48
 
57
49
  desc "Push a new version to Gemcutter"
58
- task :publish => [ :test, :gemspec, :build ] do
59
- system "git tag v#{Resque::Version}"
60
- system "git push origin v#{Resque::Version}"
61
- system "git push origin master"
62
- system "gem push pkg/resque-mongo-#{Resque::Version}.gem"
63
- system "git clean -fd"
50
+ task :publish do
51
+ require 'resque/version'
52
+
53
+ sh "gem build resque.gemspec"
54
+ sh "gem push resque-#{Resque::Version}.gem"
55
+ sh "git tag v#{Resque::Version}"
56
+ sh "git push origin v#{Resque::Version}"
57
+ sh "git push origin master"
58
+ sh "git clean -fd"
64
59
  exec "rake pages"
65
60
  end
@@ -36,8 +36,6 @@ module Resque
36
36
  @stats = @db.collection('stats')
37
37
 
38
38
  add_indexes
39
- else
40
- raise "I don't know what to do with #{server.inspect}"
41
39
  end
42
40
  end
43
41
 
@@ -101,8 +99,8 @@ module Resque
101
99
  end
102
100
 
103
101
  # The `after_fork` hook will be run in the child process and is passed
104
- # the current job. Any changes you make, therefor, will only live as
105
- # long as the job currently being processes.
102
+ # the current job. Any changes you make, therefore, will only live as
103
+ # long as the job currently being processed.
106
104
  #
107
105
  # Call with a block to set the hook.
108
106
  # Call with no arguments to return the hook.
@@ -126,10 +124,10 @@ module Resque
126
124
  end
127
125
 
128
126
  def drop
129
- @mongo.drop
130
- @workers.drop
131
- @failures.drop
132
- @stats.drop
127
+ @mongo.drop if @mongo
128
+ @workers.drop if @workers
129
+ @failures.drop if @failures
130
+ @stats.drop if @stats
133
131
  @mongo = nil
134
132
  end
135
133
 
@@ -157,7 +155,7 @@ module Resque
157
155
  raise e
158
156
  end
159
157
 
160
- # Returns an int representing the size of a queue.
158
+ # Returns an integer representing the size of a queue.
161
159
  # Queue name should be a string.
162
160
  def size(queue)
163
161
  mongo.find(:queue => queue).count
@@ -305,7 +303,8 @@ module Resque
305
303
  :workers => workers.size.to_i,
306
304
  :working => working.size,
307
305
  :failed => Stat[:failed],
308
- :servers => ["#{@con.host}:#{@con.port}"]
306
+ :servers => ["#{@con.host}:#{@con.port}"],
307
+ :environment => ENV['RAILS_ENV'] || ENV['RACK_ENV'] || 'development'
309
308
  }
310
309
  end
311
310
 
@@ -83,7 +83,7 @@ module Resque
83
83
  x.url "http://github.com/defunkt/resque"
84
84
  end
85
85
  x.error do
86
- x.class exception.class.name
86
+ x.tag! "class", exception.class.name
87
87
  x.message "#{exception.class.name}: #{exception.message}"
88
88
  x.backtrace do
89
89
  fill_in_backtrace_lines(x)
@@ -109,7 +109,7 @@ module Resque
109
109
  end
110
110
 
111
111
  def fill_in_backtrace_lines(x)
112
- exception.backtrace.each do |unparsed_line|
112
+ Array(exception.backtrace).each do |unparsed_line|
113
113
  _, file, number, method = unparsed_line.match(INPUT_FORMAT).to_a
114
114
  x.line :file => file,:number => number
115
115
  end
@@ -9,7 +9,7 @@ module Resque
9
9
  :payload => payload,
10
10
  :exception => exception.class.to_s,
11
11
  :error => exception.to_s,
12
- :backtrace => exception.backtrace,
12
+ :backtrace => Array(exception.backtrace),
13
13
  :worker => worker.to_s,
14
14
  :queue => queue
15
15
  }
@@ -25,11 +25,11 @@ module Resque
25
25
  all_failures = Resque.mongo_failures.find().sort([:natural, :desc]).skip(start).limit(count).to_a
26
26
  all_failures.size == 1 ? all_failures.first : all_failures
27
27
  end
28
-
28
+
29
29
  def self.clear
30
30
  Resque.mongo_failures.remove
31
31
  end
32
-
32
+
33
33
  def self.requeue(index)
34
34
  item = all(index)
35
35
  item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
@@ -3,23 +3,25 @@ module Resque
3
3
  # A Failure backend that uses multiple backends
4
4
  # delegates all queries to the first backend
5
5
  class Multiple < Base
6
-
6
+
7
7
  class << self
8
8
  attr_accessor :classes
9
9
  end
10
-
10
+
11
11
  def self.configure
12
12
  yield self
13
13
  Resque::Failure.backend = self
14
14
  end
15
-
15
+
16
16
  def initialize(*args)
17
+ super
17
18
  @backends = self.class.classes.map {|klass| klass.new(*args)}
18
19
  end
20
+
19
21
  def save
20
22
  @backends.each(&:save)
21
23
  end
22
-
24
+
23
25
  # The number of failures.
24
26
  def self.count
25
27
  classes.first.count
@@ -34,11 +36,15 @@ module Resque
34
36
  def self.url
35
37
  classes.first.url
36
38
  end
37
-
39
+
38
40
  # Clear all failure objects
39
41
  def self.clear
40
42
  classes.first.clear
41
43
  end
44
+
45
+ def self.requeue(*args)
46
+ classes.first.requeue(*args)
47
+ end
42
48
  end
43
49
  end
44
50
  end
@@ -141,8 +141,9 @@ module Resque
141
141
  else
142
142
  lambda do
143
143
  job.send(hook, *job_args) do
144
- job.perform(*job_args)
144
+ result = job.perform(*job_args)
145
145
  job_was_performed = true
146
+ result
146
147
  end
147
148
  end
148
149
  end
@@ -124,7 +124,7 @@ module Resque
124
124
  show page
125
125
  end
126
126
  end
127
-
127
+
128
128
  post "/queues/:id/remove" do
129
129
  Resque.remove_queue(params[:id])
130
130
  redirect u('queues')
@@ -150,7 +150,7 @@ module Resque
150
150
  Resque::Failure.clear
151
151
  redirect u('failed')
152
152
  end
153
-
153
+
154
154
  get "/failed/requeue/:index" do
155
155
  Resque::Failure.requeue(params[:index])
156
156
  if request.xhr?
@@ -11,7 +11,7 @@ module Resque
11
11
 
12
12
  def self.should_respond_with_success
13
13
  test "should respond with success" do
14
- assert last_response.ok?
14
+ assert last_response.ok?, last_response.errors
15
15
  end
16
16
  end
17
17
  end
@@ -28,15 +28,19 @@
28
28
  </div>
29
29
  </dd>
30
30
  <dt>Class</dt>
31
- <dd><code><%= job['payload']['class'] %></code></dd>
31
+ <dd><code><%= job['payload'] ? job['payload']['class'] : 'nil' %></code></dd>
32
32
  <dt>Arguments</dt>
33
- <dd><pre><%=h show_args(job['payload']['args']) %></pre></dd>
33
+ <dd><pre><%=h job['payload'] ? show_args(job['payload']['args']) : 'nil' %></pre></dd>
34
34
  <dt>Exception</td>
35
35
  <dd><code><%= job['exception'] %></code></dd>
36
36
  <dt>Error</dt>
37
37
  <dd class='error'>
38
- <a href="#" class="backtrace"><%= h(job['error']) %></a>
39
- <pre style='display:none'><%=h job['backtrace'].join("\n") %></pre>
38
+ <% if job['backtrace'] %>
39
+ <a href="#" class="backtrace"><%= h(job['error']) %></a>
40
+ <pre style='display:none'><%=h job['backtrace'].join("\n") %></pre>
41
+ <% else %>
42
+ <%=h job['error'] %>
43
+ <% end %>
40
44
  </dd>
41
45
  </dl>
42
46
  <div class='r'>
@@ -31,7 +31,7 @@
31
31
 
32
32
  <div id="footer">
33
33
  <p>Powered by <a href="http://github.com/defunkt/resque">Resque</a> v<%=Resque::Version%></p>
34
- <p>Connected to Redis on ... </p>
34
+ <p>Connected to Mongo on ... </p>
35
35
  </div>
36
36
 
37
37
  </body>
@@ -22,7 +22,7 @@
22
22
 
23
23
  <% elsif params[:id] == 'redis' %>
24
24
 
25
- <h1><%= resque.redis.server %></h1>
25
+ <h1><%= resque.redis_id %></h1>
26
26
  <table class='stats'>
27
27
  <% for key, value in resque.redis.info.to_a.sort_by { |i| i[0].to_s } %>
28
28
  <tr>
@@ -39,7 +39,7 @@
39
39
  <% elsif params[:id] == 'keys' %>
40
40
 
41
41
  <h1>Keys owned by <%= resque %></h1>
42
- <p class='sub'>(All keys are actually prefixed with "resque:")</p>
42
+ <p class='sub'>(All keys are actually prefixed with "<%= Resque.redis.namespace %>:")</p>
43
43
  <table class='stats'>
44
44
  <tr>
45
45
  <th>key</th>
@@ -19,7 +19,7 @@ namespace :resque do
19
19
  abort "set QUEUE env var, e.g. $ QUEUE=critical,high rake resque:work"
20
20
  end
21
21
 
22
- puts "*** Starting worker #{worker}"
22
+ worker.log "Starting worker #{worker}"
23
23
 
24
24
  worker.work(ENV['INTERVAL'] || 5) # interval, will block
25
25
  end
@@ -1,3 +1,3 @@
1
1
  module Resque
2
- Version = '1.8.1'
2
+ Version = VERSION = '1.9.8.1'
3
3
  end
@@ -24,7 +24,7 @@ module Resque
24
24
 
25
25
  # Returns an array of all worker objects.
26
26
  def self.all
27
- mongo_workers.distinct(:worker).map { |worker| find(worker) }
27
+ mongo_workers.distinct(:worker).map { |worker| find(worker) }.compact
28
28
  end
29
29
 
30
30
  # Returns an array of all worker objects currently processing
@@ -93,7 +93,7 @@ namespace :redis do
93
93
  end
94
94
 
95
95
  %w(redis-benchmark redis-cli redis-server).each do |bin|
96
- sh "cp /tmp/redis/#{bin} #{bin_dir}"
96
+ sh "cp /tmp/redis/src/#{bin} #{bin_dir}"
97
97
  end
98
98
 
99
99
  puts "Installed redis-benchmark, redis-cli and redis-server to #{bin_dir}"
@@ -105,8 +105,8 @@ namespace :redis do
105
105
  end
106
106
 
107
107
  task :make do
108
- sh "cd /tmp/redis && make clean"
109
- sh "cd /tmp/redis && make"
108
+ sh "cd /tmp/redis/src && make clean"
109
+ sh "cd /tmp/redis/src && make"
110
110
  end
111
111
 
112
112
  desc "Download package"