resque_utils 0.0.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/.gitignore +4 -0
- data/Gemfile +4 -0
- data/README.mdown +49 -0
- data/Rakefile +2 -0
- data/lib/resque_utils.rb +39 -0
- data/lib/resque_utils/capistrano.rb +44 -0
- data/lib/resque_utils/version.rb +3 -0
- data/resque_utils.gemspec +23 -0
- metadata +74 -0
data/.gitignore
ADDED
data/Gemfile
ADDED
data/README.mdown
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
# ResqueUtils
|
2
|
+
|
3
|
+
ResqueUtils is a gem that gives you extra helper cap commands for use with Resque.
|
4
|
+
|
5
|
+
## Requirements
|
6
|
+
|
7
|
+
* Capistrano
|
8
|
+
* Resque
|
9
|
+
|
10
|
+
## Installation
|
11
|
+
|
12
|
+
Firstly you'll need to install the gem, if you are using bundler add this to your Gemfile (but make sure it doesn't go in a gem group that isn't being sent to the server)...
|
13
|
+
|
14
|
+
``` ruby
|
15
|
+
gem 'resque_utils'
|
16
|
+
```
|
17
|
+
|
18
|
+
Open your deploy.rb and simple require the file...
|
19
|
+
|
20
|
+
``` ruby
|
21
|
+
require 'resque_utils/capistrano'
|
22
|
+
```
|
23
|
+
|
24
|
+
You'll then have the following commands available to you...
|
25
|
+
|
26
|
+
``` ruby
|
27
|
+
cap resque:failed:remove_all # Remove all failed jobs
|
28
|
+
cap resque:failed:remove_specific # Remove specific failed jobs (specify with '--set exception=SomeError')
|
29
|
+
cap resque:failed:requeue_all # Requeue all failed jobs
|
30
|
+
cap resque:failed:requeue_specific # Requeue specific failed jobs (specify with '--set exception=SomeError')
|
31
|
+
```
|
32
|
+
|
33
|
+
Obviously you won't want this to run on all your nodes, so make sure to filter to the node you want when you run it...
|
34
|
+
|
35
|
+
``` ruby
|
36
|
+
HOSTFILTER=resque.somedomain.com cap resque:failed:remove_all
|
37
|
+
```
|
38
|
+
|
39
|
+
To run the specific commands, for example to requeue any job that failed with the exception ``` SomeError ```...
|
40
|
+
|
41
|
+
``` ruby
|
42
|
+
cap resque:failed:requeue_specific --set exception=SomeError
|
43
|
+
```
|
44
|
+
|
45
|
+
You could also do something like this, although i'd *really* not recommend it...
|
46
|
+
|
47
|
+
``` ruby
|
48
|
+
before 'deploy:symlink', 'resque:failed:remove_all'
|
49
|
+
```
|
data/Rakefile
ADDED
data/lib/resque_utils.rb
ADDED
@@ -0,0 +1,39 @@
|
|
1
|
+
require 'resque_utils/version'
|
2
|
+
|
3
|
+
module ResqueUtils
|
4
|
+
|
5
|
+
def self.requeue_all
|
6
|
+
count = Resque::Failure.count-1
|
7
|
+
count.downto(0).each { |i| Resque::Failure.requeue(i) }
|
8
|
+
puts "#{count} jobs requeued"
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.remove_all
|
12
|
+
count = Resque::Failure.count-1
|
13
|
+
count.downto(0).each { |i| Resque::Failure.remove(i) }
|
14
|
+
puts "#{count} jobs removed"
|
15
|
+
end
|
16
|
+
|
17
|
+
def self.requeue_specific(exception)
|
18
|
+
count = 0
|
19
|
+
(Resque::Failure.count-1).downto(0).each { |i|
|
20
|
+
if Resque::Failure.all(i)['exception'] == exception
|
21
|
+
Resque::Failure.requeue(i)
|
22
|
+
count += 1
|
23
|
+
end
|
24
|
+
}
|
25
|
+
puts "#{count} jobs requeued"
|
26
|
+
end
|
27
|
+
|
28
|
+
def self.remove_specific(exception)
|
29
|
+
count = 0
|
30
|
+
(Resque::Failure.count-1).downto(0).each { |i|
|
31
|
+
if Resque::Failure.all(i)['exception'] == exception
|
32
|
+
Resque::Failure.remove(i)
|
33
|
+
count += 1
|
34
|
+
end
|
35
|
+
}
|
36
|
+
puts "#{count} jobs removed"
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'resque_utils'
|
2
|
+
|
3
|
+
Capistrano::Configuration.instance(:must_exist).load do
|
4
|
+
|
5
|
+
namespace :resque do
|
6
|
+
|
7
|
+
namespace :failed do
|
8
|
+
|
9
|
+
desc "Requeue all failed jobs"
|
10
|
+
task :requeue_all do
|
11
|
+
set :resque_pre, "#{current_path} && RAILS_ENV=#{environment} bundle exec rails runner"
|
12
|
+
run "#{resque_pre} 'ResqueUtils::requeue_all'"
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Remove all failed jobs"
|
16
|
+
task :remove_all do
|
17
|
+
set :resque_pre, "#{current_path} && RAILS_ENV=#{environment} bundle exec rails runner"
|
18
|
+
run "#{resque_pre} 'ResqueUtils::remove_all'"
|
19
|
+
end
|
20
|
+
|
21
|
+
desc "Requeue specific failed jobs (specify with '--set exception=SomeErrorHere)"
|
22
|
+
task :requeue_specific do
|
23
|
+
if exists?(:exception)
|
24
|
+
set :resque_pre, "#{current_path} && RAILS_ENV=#{environment} bundle exec rails runner"
|
25
|
+
run "#{resque_pre} \"ResqueUtils::requeue_all('#{exception}')\""
|
26
|
+
else
|
27
|
+
raise ArgumentError, "No exception was specified, use '--set exception=SomeErrorHere'"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
desc "Remove specific failed jobs (specify with '--set exception=SomeErrorHere)"
|
32
|
+
task :remove_specific do
|
33
|
+
if exists?(:exception)
|
34
|
+
set :resque_pre, "#{current_path} && RAILS_ENV=#{environment} bundle exec rails runner"
|
35
|
+
run "#{resque_pre} \"ResqueUtils::remove_all('#{exception}')\""
|
36
|
+
else
|
37
|
+
raise ArgumentError, "No exception was specified, use '--set exception=SomeErrorHere'"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# -*- encoding: utf-8 -*-
|
2
|
+
$:.push File.expand_path("../lib", __FILE__)
|
3
|
+
require "resque_utils/version"
|
4
|
+
|
5
|
+
Gem::Specification.new do |s|
|
6
|
+
s.name = "resque_utils"
|
7
|
+
s.version = ResqueUtils::VERSION
|
8
|
+
s.platform = Gem::Platform::RUBY
|
9
|
+
s.authors = ["Lloyd Pick"]
|
10
|
+
s.email = ["lloyd.pick@forward.co.uk"]
|
11
|
+
s.homepage = ""
|
12
|
+
s.summary = %q{Provides some extra cap commands for Resque}
|
13
|
+
s.description = %q{Provides extra help cap commands for use with Resque, requeuing jobs, mass deleting jobs}
|
14
|
+
|
15
|
+
s.rubyforge_project = "resque_utils"
|
16
|
+
|
17
|
+
s.files = `git ls-files`.split("\n")
|
18
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
19
|
+
s.executables = `git ls-files -- bin/*`.split("\n").map{ |f| File.basename(f) }
|
20
|
+
s.require_paths = ["lib"]
|
21
|
+
|
22
|
+
s.add_development_dependency(%q<rake>)
|
23
|
+
end
|
metadata
ADDED
@@ -0,0 +1,74 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: resque_utils
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Lloyd Pick
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2011-08-17 00:00:00.000000000 +01:00
|
13
|
+
default_executable:
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: rake
|
17
|
+
requirement: &2152873080 !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0'
|
23
|
+
type: :development
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: *2152873080
|
26
|
+
description: Provides extra help cap commands for use with Resque, requeuing jobs,
|
27
|
+
mass deleting jobs
|
28
|
+
email:
|
29
|
+
- lloyd.pick@forward.co.uk
|
30
|
+
executables: []
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- .gitignore
|
35
|
+
- Gemfile
|
36
|
+
- Gemfile.lock
|
37
|
+
- README.mdown
|
38
|
+
- Rakefile
|
39
|
+
- lib/resque_utils.rb
|
40
|
+
- lib/resque_utils/capistrano.rb
|
41
|
+
- lib/resque_utils/version.rb
|
42
|
+
- resque_utils.gemspec
|
43
|
+
has_rdoc: true
|
44
|
+
homepage: ''
|
45
|
+
licenses: []
|
46
|
+
post_install_message:
|
47
|
+
rdoc_options: []
|
48
|
+
require_paths:
|
49
|
+
- lib
|
50
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
51
|
+
none: false
|
52
|
+
requirements:
|
53
|
+
- - ! '>='
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '0'
|
56
|
+
segments:
|
57
|
+
- 0
|
58
|
+
hash: 3008698848086049271
|
59
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
60
|
+
none: false
|
61
|
+
requirements:
|
62
|
+
- - ! '>='
|
63
|
+
- !ruby/object:Gem::Version
|
64
|
+
version: '0'
|
65
|
+
segments:
|
66
|
+
- 0
|
67
|
+
hash: 3008698848086049271
|
68
|
+
requirements: []
|
69
|
+
rubyforge_project: resque_utils
|
70
|
+
rubygems_version: 1.6.2
|
71
|
+
signing_key:
|
72
|
+
specification_version: 3
|
73
|
+
summary: Provides some extra cap commands for Resque
|
74
|
+
test_files: []
|