resque-mongo 1.8.1 → 1.9.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/HISTORY.md +70 -0
- data/README.markdown +7 -2
- data/Rakefile +25 -30
- data/lib/resque.rb +9 -10
- data/lib/resque/failure/hoptoad.rb +2 -2
- data/lib/resque/failure/mongo.rb +3 -3
- data/lib/resque/failure/multiple.rb +11 -5
- data/lib/resque/job.rb +2 -1
- data/lib/resque/server.rb +2 -2
- data/lib/resque/server/test_helper.rb +1 -1
- data/lib/resque/server/views/failed.erb +8 -4
- data/lib/resque/server/views/layout.erb +1 -1
- data/lib/resque/server/views/stats.erb +2 -2
- data/lib/resque/tasks.rb +1 -1
- data/lib/resque/version.rb +1 -1
- data/lib/resque/worker.rb +1 -1
- data/tasks/redis.rake +3 -3
- data/test/job_hooks_test.rb +14 -14
- data/test/job_plugins_test.rb +29 -8
- data/test/plugin_test.rb +8 -8
- data/test/redis-test.conf +0 -17
- data/test/resque-web_test.rb +0 -20
- metadata +47 -73
- data/.gitignore +0 -3
- data/.kick +0 -26
- data/CONTRIBUTORS +0 -32
- data/config.ru +0 -14
- data/deps.rip +0 -8
- data/docs/HOOKS.md +0 -121
- data/docs/PLUGINS.md +0 -93
- data/examples/async_helper.rb +0 -31
- data/examples/demo/README.markdown +0 -71
- data/examples/demo/Rakefile +0 -8
- data/examples/demo/app.rb +0 -38
- data/examples/demo/config.ru +0 -19
- data/examples/demo/job.rb +0 -22
- data/examples/god/resque.god +0 -53
- data/examples/god/stale.god +0 -26
- data/examples/instance.rb +0 -11
- data/examples/monit/resque.monit +0 -6
- data/examples/simple.rb +0 -30
- data/init.rb +0 -1
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.
|
data/README.markdown
CHANGED
@@ -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
|
-
|
26
|
-
|
33
|
+
#
|
34
|
+
# Install
|
35
|
+
#
|
27
36
|
|
28
|
-
|
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
|
-
|
42
|
-
|
43
|
-
|
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
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
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
|
data/lib/resque.rb
CHANGED
@@ -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,
|
105
|
-
# long as the job currently being
|
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
|
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
|
data/lib/resque/failure/mongo.rb
CHANGED
@@ -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
|
data/lib/resque/job.rb
CHANGED
data/lib/resque/server.rb
CHANGED
@@ -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?
|
@@ -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
|
-
|
39
|
-
|
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'>
|
@@ -22,7 +22,7 @@
|
|
22
22
|
|
23
23
|
<% elsif params[:id] == 'redis' %>
|
24
24
|
|
25
|
-
<h1><%= resque.
|
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 "
|
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>
|
data/lib/resque/tasks.rb
CHANGED
data/lib/resque/version.rb
CHANGED
data/lib/resque/worker.rb
CHANGED
@@ -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
|
data/tasks/redis.rake
CHANGED
@@ -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"
|