resque-multiple-failure-backend 1.0.0
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/Gemfile +4 -0
- data/Gemfile.lock +42 -0
- data/LICENSE +20 -0
- data/README.mdown +26 -0
- data/Rakefile +54 -0
- data/VERSION +1 -0
- data/lib/resque/failure/multiple_failure.rb +62 -0
- data/lib/resque/failure_server.rb +43 -0
- data/lib/resque/server/views/failure_queue.erb +54 -0
- data/lib/resque/server/views/failures.erb +24 -0
- data/test/helper.rb +10 -0
- data/test/test_resque-multiple-failure-backend.rb +7 -0
- metadata +107 -0
data/Gemfile
ADDED
data/Gemfile.lock
ADDED
@@ -0,0 +1,42 @@
|
|
1
|
+
PATH
|
2
|
+
remote: .
|
3
|
+
specs:
|
4
|
+
resque-multiple-failure-backend (0.0.0)
|
5
|
+
resque
|
6
|
+
|
7
|
+
GEM
|
8
|
+
remote: http://rubygems.org/
|
9
|
+
specs:
|
10
|
+
gemcutter (0.6.1)
|
11
|
+
git (1.2.5)
|
12
|
+
jeweler (1.4.0)
|
13
|
+
gemcutter (>= 0.1.0)
|
14
|
+
git (>= 1.2.5)
|
15
|
+
rubyforge (>= 2.0.0)
|
16
|
+
json (1.4.6)
|
17
|
+
json_pure (1.4.6)
|
18
|
+
rack (1.2.1)
|
19
|
+
redis (2.0.10)
|
20
|
+
redis-namespace (0.8.0)
|
21
|
+
redis (< 3.0.0)
|
22
|
+
resque (1.10.0)
|
23
|
+
json (~> 1.4.6)
|
24
|
+
redis-namespace (~> 0.8.0)
|
25
|
+
sinatra (>= 0.9.2)
|
26
|
+
vegas (~> 0.1.2)
|
27
|
+
rubyforge (2.0.4)
|
28
|
+
json_pure (>= 1.1.7)
|
29
|
+
sinatra (1.0)
|
30
|
+
rack (>= 1.0)
|
31
|
+
thoughtbot-shoulda (2.11.1)
|
32
|
+
vegas (0.1.7)
|
33
|
+
rack (>= 1.0.0)
|
34
|
+
|
35
|
+
PLATFORMS
|
36
|
+
ruby
|
37
|
+
|
38
|
+
DEPENDENCIES
|
39
|
+
jeweler
|
40
|
+
resque
|
41
|
+
resque-multiple-failure-backend!
|
42
|
+
thoughtbot-shoulda
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 Adam Holt
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.mdown
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
# resque-multiple-failure-backend
|
2
|
+
|
3
|
+
## Usage
|
4
|
+
|
5
|
+
### In ~/resque_conf.rb
|
6
|
+
|
7
|
+
require 'resque/failure/multiple_failure'
|
8
|
+
require 'resque/failure_server'
|
9
|
+
|
10
|
+
### In your worker application
|
11
|
+
|
12
|
+
Resque::Failure.backend = Resque::Failure::MultipleFailure
|
13
|
+
|
14
|
+
## Note on Patches/Pull Requests
|
15
|
+
|
16
|
+
* Fork the project.
|
17
|
+
* Make your feature addition or bug fix.
|
18
|
+
* Add tests for it. This is important so I don't break it in a
|
19
|
+
future version unintentionally.
|
20
|
+
* Commit, do not mess with rakefile, version, or history.
|
21
|
+
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull)
|
22
|
+
* Send me a pull request. Bonus points for topic branches.
|
23
|
+
|
24
|
+
## Copyright
|
25
|
+
|
26
|
+
Copyright (c) 2010 Adam Holt. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'jeweler'
|
6
|
+
Jeweler::Tasks.new do |gem|
|
7
|
+
gem.name = "resque-multiple-failure-backend"
|
8
|
+
gem.summary = %Q{Adds a failed queue for each queue}
|
9
|
+
gem.description = %Q{Individual failed queue for each queue you have}
|
10
|
+
gem.email = "Ads.noob@gmail.com"
|
11
|
+
gem.homepage = "http://github.com/omgitsads/resque-multiple-failure-backend"
|
12
|
+
gem.authors = ["Adam Holt"]
|
13
|
+
gem.add_development_dependency "thoughtbot-shoulda", ">= 0"
|
14
|
+
gem.files = FileList["[A-Z]*", "{bin,generators,lib,test}/**/*", 'lib/jeweler/templates/.gitignore']
|
15
|
+
gem.add_dependency "resque", ">= 0"
|
16
|
+
end
|
17
|
+
Jeweler::GemcutterTasks.new
|
18
|
+
rescue LoadError
|
19
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
20
|
+
end
|
21
|
+
|
22
|
+
require 'rake/testtask'
|
23
|
+
Rake::TestTask.new(:test) do |test|
|
24
|
+
test.libs << 'lib' << 'test'
|
25
|
+
test.pattern = 'test/**/test_*.rb'
|
26
|
+
test.verbose = true
|
27
|
+
end
|
28
|
+
|
29
|
+
begin
|
30
|
+
require 'rcov/rcovtask'
|
31
|
+
Rcov::RcovTask.new do |test|
|
32
|
+
test.libs << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
rescue LoadError
|
37
|
+
task :rcov do
|
38
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
task :test => :check_dependencies
|
43
|
+
|
44
|
+
task :default => :test
|
45
|
+
|
46
|
+
require 'rake/rdoctask'
|
47
|
+
Rake::RDocTask.new do |rdoc|
|
48
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
49
|
+
|
50
|
+
rdoc.rdoc_dir = 'rdoc'
|
51
|
+
rdoc.title = "resque-multiple-failure-backend #{version}"
|
52
|
+
rdoc.rdoc_files.include('README*')
|
53
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
54
|
+
end
|
data/VERSION
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
1.0.0
|
@@ -0,0 +1,62 @@
|
|
1
|
+
module Resque
|
2
|
+
module Failure
|
3
|
+
class MultipleFailure < Base
|
4
|
+
def save
|
5
|
+
data = {
|
6
|
+
:failed_at => Time.now.strftime("%Y/%m/%d %H:%M:%S"),
|
7
|
+
:payload => payload,
|
8
|
+
:exception => exception.class.to_s,
|
9
|
+
:error => exception.to_s,
|
10
|
+
:backtrace => Array(exception.backtrace),
|
11
|
+
:worker => worker.to_s,
|
12
|
+
:queue => queue
|
13
|
+
}
|
14
|
+
data = Resque.encode(data)
|
15
|
+
Resque.redis.rpush("failed_#{queue}".to_sym, data)
|
16
|
+
end
|
17
|
+
|
18
|
+
def self.queues
|
19
|
+
Resque.queues.map {|queue| "failed_#{queue}"}
|
20
|
+
end
|
21
|
+
|
22
|
+
def self.count(queue=nil)
|
23
|
+
if queue
|
24
|
+
queue = queue =~ /^failed_/ ? queue : "failed_#{queue}"
|
25
|
+
Resque.redis.llen(queue.to_sym).to_i
|
26
|
+
else
|
27
|
+
count = 0
|
28
|
+
Resque.queues.each do |queue|
|
29
|
+
count += Resque.redis.llen("failed_#{queue}".to_sym).to_i
|
30
|
+
end
|
31
|
+
count
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
def self.url
|
36
|
+
"/failed/list"
|
37
|
+
end
|
38
|
+
|
39
|
+
def self.all(queue, start = 0, count = 1)
|
40
|
+
queue = queue =~ /^failed_/ ? queue : "failed_#{queue}"
|
41
|
+
Resque.list_range(queue.to_sym, start, count)
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.clear(queue=nil)
|
45
|
+
if queue
|
46
|
+
queue = queue =~ /^failed_/ ? queue : "failed_#{queue}"
|
47
|
+
Resque.redis.del(queue.to_sym)
|
48
|
+
else
|
49
|
+
Resque.queues.each {|queue| Resque.redis.del("failed_#{queue}") }
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def self.requeue(queue, index)
|
54
|
+
queue = queue =~ /^failed_/ ? queue : "failed_#{queue}"
|
55
|
+
item = all(queue, index)
|
56
|
+
item['retried_at'] = Time.now.strftime("%Y/%m/%d %H:%M:%S")
|
57
|
+
Resque.redis.lset(queue.to_sym, index, Resque.encode(item))
|
58
|
+
Job.create(item['queue'], item['payload']['class'], *item['payload']['args'])
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'resque'
|
2
|
+
|
3
|
+
module Resque
|
4
|
+
module FailureServer
|
5
|
+
VIEW_PATH = File.join(File.dirname(__FILE__), 'server', 'views')
|
6
|
+
|
7
|
+
def self.registered(app)
|
8
|
+
app.get '/failed/list' do
|
9
|
+
@queues = Resque::Failure.backend.queues
|
10
|
+
failures_view(:failures)
|
11
|
+
end
|
12
|
+
|
13
|
+
app.get '/failed/:queue' do
|
14
|
+
@start = params[:start].to_i || 0
|
15
|
+
@failed = Resque::Failure.backend.all(params[:queue], @start, 20)
|
16
|
+
failures_view(:failure_queue)
|
17
|
+
end
|
18
|
+
|
19
|
+
app.post '/failed/:queue/clear' do
|
20
|
+
Resque::Failure.backend.clear(params[:queue])
|
21
|
+
redirect u("failures/#{params[:queue]}")
|
22
|
+
end
|
23
|
+
|
24
|
+
app.get '/failed/:queue/requeue/:id' do
|
25
|
+
Resque::Failure.backend.requeue(params[:queue], params[:id])
|
26
|
+
if request.xhr?
|
27
|
+
return Resque::Failure.backend.all(params[:queue], params[:index])['retried_at']
|
28
|
+
else
|
29
|
+
redirect u("failure/#{params[:queue]}")
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
app.helpers do
|
34
|
+
def failures_view(filename, options = {}, locals = {})
|
35
|
+
erb(File.read(File.join(::Resque::FailureServer::VIEW_PATH, "#{filename}.erb")), options, locals)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
Resque::Server.register Resque::FailureServer
|
@@ -0,0 +1,54 @@
|
|
1
|
+
<% queue = params[:queue] %>
|
2
|
+
<%start = params[:start].to_i %>
|
3
|
+
|
4
|
+
<% index = 0 %>
|
5
|
+
<h1>Failed Jobs on <%= queue %></h1>
|
6
|
+
|
7
|
+
<%unless @failed.empty?%>
|
8
|
+
<form method="POST" action="<%=u :failed, queue, :clear %>" class='clear-failed'>
|
9
|
+
<input type='submit' name='' value='Clear Failed Jobs' />
|
10
|
+
</form>
|
11
|
+
<%end%>
|
12
|
+
|
13
|
+
<p class='sub'>Showing <%= start %> to <%= start + 20 %> of <b><%= size = Resque::Failure.backend.count(@queue) %></b> jobs</p>
|
14
|
+
|
15
|
+
<ul class='failed'>
|
16
|
+
<%for job in @failed%>
|
17
|
+
<% index += 1 %>
|
18
|
+
<li>
|
19
|
+
<dl>
|
20
|
+
<dt>Worker</dt>
|
21
|
+
<dd>
|
22
|
+
<a href="<%= url(:workers, job['worker']) %>"><%= job['worker'].split(':')[0...2].join(':') %></a> on <b class='queue-tag'><%= job['queue'] %></b > at <b><span class="time"><%= job['failed_at'] %></span></b>
|
23
|
+
<div class='retry'>
|
24
|
+
<% if job['retried_at'] %>
|
25
|
+
Retried <b><span class="time"><%= job['retried_at'] %></span></b>
|
26
|
+
<% else %>
|
27
|
+
<a href="<%= u "failed/#{queue}/requeue/#{start + index - 1}" %>" rel="retry">Retry</a>
|
28
|
+
<% end %>
|
29
|
+
</div>
|
30
|
+
</dd>
|
31
|
+
<dt>Class</dt>
|
32
|
+
<dd><code><%= job['payload'] ? job['payload']['class'] : 'nil' %></code></dd>
|
33
|
+
<dt>Arguments</dt>
|
34
|
+
<dd><pre><%=h job['payload'] ? show_args(job['payload']['args']) : 'nil' %></pre></dd>
|
35
|
+
<dt>Exception</td>
|
36
|
+
<dd><code><%= job['exception'] %></code></dd>
|
37
|
+
<dt>Error</dt>
|
38
|
+
<dd class='error'>
|
39
|
+
<% if job['backtrace'] %>
|
40
|
+
<a href="#" class="backtrace"><%= h(job['error']) %></a>
|
41
|
+
<pre style='display:none'><%=h job['backtrace'].join("\n") %></pre>
|
42
|
+
<% else %>
|
43
|
+
<%=h job['error'] %>
|
44
|
+
<% end %>
|
45
|
+
</dd>
|
46
|
+
</dl>
|
47
|
+
<div class='r'>
|
48
|
+
</div>
|
49
|
+
</li>
|
50
|
+
<%end%>
|
51
|
+
</ul>
|
52
|
+
|
53
|
+
<%= partial :next_more, :start => start, :size => size %>
|
54
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<style type="text/css" media="screen">
|
2
|
+
#main table.queues tr.failed td {
|
3
|
+
border-top: 0;
|
4
|
+
}
|
5
|
+
#main table.queues tr.failure td {
|
6
|
+
border-top: 0;
|
7
|
+
}
|
8
|
+
</style>
|
9
|
+
|
10
|
+
<h1 class="wi">Failed Jobs</h1>
|
11
|
+
<p class="intro">Jobs that have failed.</p>
|
12
|
+
|
13
|
+
<table class='queues'>
|
14
|
+
<tr>
|
15
|
+
<th>Name</th>
|
16
|
+
<th>Failures</th>
|
17
|
+
</tr>
|
18
|
+
<% for queue in @queues.sort_by { |q| q.to_s } %>
|
19
|
+
<tr class="<%= Resque::Failure.backend.count(queue).zero? ? "failed" : "failure" %>">
|
20
|
+
<td class='queue failed'><a class="queue" href="<%= url :failed, queue %>"><%= queue %></a></td>
|
21
|
+
<td class='size'><%= Resque::Failure.backend.count(queue) %></td>
|
22
|
+
</tr>
|
23
|
+
<% end %>
|
24
|
+
</table>
|
data/test/helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,107 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resque-multiple-failure-backend
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
hash: 23
|
5
|
+
prerelease: false
|
6
|
+
segments:
|
7
|
+
- 1
|
8
|
+
- 0
|
9
|
+
- 0
|
10
|
+
version: 1.0.0
|
11
|
+
platform: ruby
|
12
|
+
authors:
|
13
|
+
- Adam Holt
|
14
|
+
autorequire:
|
15
|
+
bindir: bin
|
16
|
+
cert_chain: []
|
17
|
+
|
18
|
+
date: 2010-10-21 00:00:00 +01:00
|
19
|
+
default_executable:
|
20
|
+
dependencies:
|
21
|
+
- !ruby/object:Gem::Dependency
|
22
|
+
name: thoughtbot-shoulda
|
23
|
+
prerelease: false
|
24
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ">="
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
hash: 3
|
30
|
+
segments:
|
31
|
+
- 0
|
32
|
+
version: "0"
|
33
|
+
type: :development
|
34
|
+
version_requirements: *id001
|
35
|
+
- !ruby/object:Gem::Dependency
|
36
|
+
name: resque
|
37
|
+
prerelease: false
|
38
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
39
|
+
none: false
|
40
|
+
requirements:
|
41
|
+
- - ">="
|
42
|
+
- !ruby/object:Gem::Version
|
43
|
+
hash: 3
|
44
|
+
segments:
|
45
|
+
- 0
|
46
|
+
version: "0"
|
47
|
+
type: :runtime
|
48
|
+
version_requirements: *id002
|
49
|
+
description: Individual failed queue for each queue you have
|
50
|
+
email: Ads.noob@gmail.com
|
51
|
+
executables: []
|
52
|
+
|
53
|
+
extensions: []
|
54
|
+
|
55
|
+
extra_rdoc_files:
|
56
|
+
- LICENSE
|
57
|
+
- README.mdown
|
58
|
+
files:
|
59
|
+
- Gemfile
|
60
|
+
- Gemfile.lock
|
61
|
+
- LICENSE
|
62
|
+
- README.mdown
|
63
|
+
- Rakefile
|
64
|
+
- VERSION
|
65
|
+
- lib/resque/failure/multiple_failure.rb
|
66
|
+
- lib/resque/failure_server.rb
|
67
|
+
- lib/resque/server/views/failure_queue.erb
|
68
|
+
- lib/resque/server/views/failures.erb
|
69
|
+
- test/helper.rb
|
70
|
+
- test/test_resque-multiple-failure-backend.rb
|
71
|
+
has_rdoc: true
|
72
|
+
homepage: http://github.com/omgitsads/resque-multiple-failure-backend
|
73
|
+
licenses: []
|
74
|
+
|
75
|
+
post_install_message:
|
76
|
+
rdoc_options:
|
77
|
+
- --charset=UTF-8
|
78
|
+
require_paths:
|
79
|
+
- lib
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
81
|
+
none: false
|
82
|
+
requirements:
|
83
|
+
- - ">="
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
hash: 3
|
86
|
+
segments:
|
87
|
+
- 0
|
88
|
+
version: "0"
|
89
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ">="
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
hash: 3
|
95
|
+
segments:
|
96
|
+
- 0
|
97
|
+
version: "0"
|
98
|
+
requirements: []
|
99
|
+
|
100
|
+
rubyforge_project:
|
101
|
+
rubygems_version: 1.3.7
|
102
|
+
signing_key:
|
103
|
+
specification_version: 3
|
104
|
+
summary: Adds a failed queue for each queue
|
105
|
+
test_files:
|
106
|
+
- test/helper.rb
|
107
|
+
- test/test_resque-multiple-failure-backend.rb
|