resque-cleaner 0.2.5 → 0.2.6
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG.md +4 -0
- data/README.markdown +40 -0
- data/lib/resque_cleaner/server/views/cleaner_list.erb +2 -1
- metadata +4 -4
data/CHANGELOG.md
CHANGED
data/README.markdown
CHANGED
@@ -32,7 +32,9 @@ Resque-Web integration
|
|
32
32
|
|
33
33
|
You have to load ResqueCleaner to enable the Cleaner tab.
|
34
34
|
|
35
|
+
```ruby
|
35
36
|
require 'resque-cleaner'
|
37
|
+
```
|
36
38
|
|
37
39
|
Console
|
38
40
|
-------
|
@@ -43,70 +45,88 @@ you to understand what is going on with your console(irb).
|
|
43
45
|
|
44
46
|
**Create Instance**
|
45
47
|
|
48
|
+
```ruby
|
46
49
|
> cleaner = Resque::Plugins::ResqueCleaner.new
|
50
|
+
```
|
47
51
|
|
48
52
|
**Show Stats**
|
49
53
|
|
50
54
|
Shows stats of failed jobs grouped by date.
|
51
55
|
|
56
|
+
```ruby
|
52
57
|
> cleaner.stats_by_date
|
53
58
|
2009/03/13: 6
|
54
59
|
2009/11/13: 14
|
55
60
|
2010/08/13: 22
|
56
61
|
total: 42
|
57
62
|
=> {'2009/03/10' => 6, ...}
|
63
|
+
```
|
58
64
|
|
59
65
|
You could also group them by class.
|
60
66
|
|
67
|
+
```ruby
|
61
68
|
> cleaner.stats_by_class
|
62
69
|
BadJob: 3
|
63
70
|
HorribleJob: 7
|
64
71
|
total: 10
|
65
72
|
=> {'BadJob' => 3, ...}
|
73
|
+
```
|
66
74
|
|
67
75
|
Or you could also group them by exception.
|
68
76
|
|
77
|
+
```ruby
|
69
78
|
> cleaner.stats_by_exception
|
70
79
|
RuntimeError: 35
|
71
80
|
SyntaxError: 7
|
72
81
|
total: 42
|
73
82
|
=> {'RuntimeError' => 35, ...}
|
83
|
+
```
|
74
84
|
|
75
85
|
You can get the ones filtered with a block: it targets only jobs which the block
|
76
86
|
evaluates true.
|
77
87
|
|
78
88
|
e.g. Show stats only of jobs entered with some arguments:
|
79
89
|
|
90
|
+
```ruby
|
80
91
|
> cleaner.stats_by_date {|j| j["payload"]["args"].size > 0}
|
81
92
|
2009/03/13: 3
|
82
93
|
2009/11/13: 7
|
83
94
|
2010/08/13: 11
|
84
95
|
total: 22
|
85
96
|
=> {'2009/03/10' => 3, ...}
|
97
|
+
```
|
86
98
|
|
87
99
|
**Retry(Requeue) Jobs**
|
88
100
|
|
89
101
|
You can retry all failed jobs with this method.
|
90
102
|
|
103
|
+
```ruby
|
91
104
|
> cleaner.requeue
|
105
|
+
```
|
92
106
|
|
93
107
|
Of course, you can filter jobs with a block; it requeues only jobs which the
|
94
108
|
block evaluates true.
|
95
109
|
|
96
110
|
e.g. Retry only jobs with some arguments:
|
97
111
|
|
112
|
+
```ruby
|
98
113
|
> cleaner.requeue {|j| j["payload"]["args"].size > 0}
|
114
|
+
```
|
99
115
|
|
100
116
|
The job hash is extended with a module which defines some useful methods. You
|
101
117
|
can use it in the block.
|
102
118
|
|
103
119
|
e.g. Retry only jobs entered within a day:
|
104
120
|
|
121
|
+
```ruby
|
105
122
|
> cleaner.requeue {|j| j.after?(1.day.ago)}
|
123
|
+
```
|
106
124
|
|
107
125
|
e.g. Retry EmailJob entered with arguments within 3 days:
|
108
126
|
|
127
|
+
```ruby
|
109
128
|
> cleaner.requeue {|j| j.after?(3.days.ago) && j.klass?(EmailJob) && j["payload"]["args"].size>0}
|
129
|
+
```
|
110
130
|
|
111
131
|
See Helper Methods section bellow for more information.
|
112
132
|
|
@@ -118,11 +138,14 @@ is not in standard library. Using it for making explanation more understandable.
|
|
118
138
|
|
119
139
|
You can clear all failed jobs with this method:
|
120
140
|
|
141
|
+
```ruby
|
121
142
|
> cleaner.clear
|
143
|
+
```
|
122
144
|
|
123
145
|
Like you can do with the retry method, the clear method takes a block. Here are
|
124
146
|
some examples:
|
125
147
|
|
148
|
+
```ruby
|
126
149
|
> cleaner.clear {|j| j.retried?}
|
127
150
|
=> clears all jobs already retried and returns number of the jobs.
|
128
151
|
|
@@ -131,6 +154,7 @@ some examples:
|
|
131
154
|
|
132
155
|
> cleaner.clear {|j| j.exception?("RuntimeError") && j.queue?(:low)}
|
133
156
|
=> clears all jobs raised RuntimeError and queued :low queue
|
157
|
+
```
|
134
158
|
|
135
159
|
**Retry and Clear Jobs**
|
136
160
|
|
@@ -139,7 +163,9 @@ as an argument.
|
|
139
163
|
|
140
164
|
e.g. Retry EmailJob and remove from failed jobs:
|
141
165
|
|
166
|
+
```ruby
|
142
167
|
> cleaner.requeue(true) {|j| j.klass?(EmailJob)}
|
168
|
+
```
|
143
169
|
|
144
170
|
**Retry with other queue**
|
145
171
|
|
@@ -148,7 +174,9 @@ jobs without blocking jobs being entered by your service running in the live.
|
|
148
174
|
|
149
175
|
e.g. Retry failed jobs on :retry queue
|
150
176
|
|
177
|
+
```ruby
|
151
178
|
> cleaner.requeue(false, :queue => :retry)
|
179
|
+
```
|
152
180
|
|
153
181
|
Don't forget to launch resque worker for the queue.
|
154
182
|
|
@@ -158,9 +186,11 @@ Don't forget to launch resque worker for the queue.
|
|
158
186
|
|
159
187
|
You can just select the jobs of course. Here are some examples:
|
160
188
|
|
189
|
+
```ruby
|
161
190
|
> cleaner.select {|j| j["payload"]["args"][0]=="Johonson"}
|
162
191
|
> cleaner.select {|j| j.after?(2.days.ago)}
|
163
192
|
> cleaner.select #=> returns all jobs
|
193
|
+
```
|
164
194
|
|
165
195
|
**Helper Methods**
|
166
196
|
|
@@ -217,35 +247,44 @@ Let's see how it works with an following example.
|
|
217
247
|
|
218
248
|
Default limiter is 1000 so that the limiter returns 1000 as a count.
|
219
249
|
|
250
|
+
```ruby
|
220
251
|
> cleaner.limiter.count
|
221
252
|
=> 1,000
|
222
253
|
> cleaner.failure.count
|
223
254
|
=> 100,000
|
255
|
+
```
|
224
256
|
|
225
257
|
You could know if the limiter is on with on? method.
|
226
258
|
|
259
|
+
```ruby
|
227
260
|
> cleaner.limiter.on?
|
228
261
|
=> true
|
262
|
+
```
|
229
263
|
|
230
264
|
You can change the maximum number of the limiter with maximum attribute.
|
231
265
|
|
266
|
+
```ruby
|
232
267
|
> cleaner.limiter.maxmum = 3000
|
233
268
|
=> 3,000
|
234
269
|
> cleaner.limiter.count
|
235
270
|
=> 3,000
|
236
271
|
> cleaner.limiter.on?
|
237
272
|
=> true
|
273
|
+
```
|
238
274
|
|
239
275
|
With limiter, ResqueCleaner's filtering targets only the last X(3000 in this
|
240
276
|
sample) failed jobs.
|
241
277
|
|
278
|
+
```ruby
|
242
279
|
> cleaner.select.size
|
243
280
|
=> 3,000
|
281
|
+
```
|
244
282
|
|
245
283
|
The clear\_stale method deletes all jobs entered prior to the last X(3000 in
|
246
284
|
this sample) failed jobs. This calls Redis API and no iteration occurs on Ruby
|
247
285
|
application; it should be quick even if there are huge number of failed jobs.
|
248
286
|
|
287
|
+
```ruby
|
249
288
|
> cleaner.clear_stale
|
250
289
|
> cleaner.failure.count
|
251
290
|
=> 3,000
|
@@ -253,6 +292,7 @@ application; it should be quick even if there are huge number of failed jobs.
|
|
253
292
|
=> 3,000
|
254
293
|
> cleaner.limiter.on?
|
255
294
|
=> false
|
295
|
+
```
|
256
296
|
|
257
297
|
Many Thanks!
|
258
298
|
------------
|
@@ -57,6 +57,7 @@
|
|
57
57
|
<% start = 0 %>
|
58
58
|
<% failed = @paginate.paginated_jobs%>
|
59
59
|
<% index = 0 %>
|
60
|
+
<% date_format = "%Y/%m/%d %T %z" %>
|
60
61
|
|
61
62
|
<% if @paginate.max_page > 0 %>
|
62
63
|
<%= erb File.read(ResqueCleaner::Server.erb_path("_paginate.erb")) %>
|
@@ -75,7 +76,7 @@
|
|
75
76
|
<dd> </dd>
|
76
77
|
<dt>Worker</dt>
|
77
78
|
<dd>
|
78
|
-
<a href="<%= u(: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>
|
79
|
+
<a href="<%= u(:workers, job['worker']) %>"><%= job['worker'].split(':')[0...2].join(':') %></a> on <b class='queue-tag'><%= job['queue'] %></b > at <b><span class="time"><%= Time.parse(job['failed_at']).strftime(date_format) %></span></b>
|
79
80
|
<% if job['retried_at'] %>
|
80
81
|
<div class='retried'>
|
81
82
|
Retried <b><span class="time"><%= job['retried_at'] %></span></b>
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: resque-cleaner
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 2
|
9
|
-
-
|
10
|
-
version: 0.2.
|
9
|
+
- 6
|
10
|
+
version: 0.2.6
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Tatsuya Ono
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
18
|
+
date: 2011-08-23 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|