resque_ui 3.1.7 → 3.2.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/History.txt +6 -0
- data/README.markdown +93 -4
- data/VERSION.yml +2 -2
- data/app/controllers/resque_controller.rb +12 -0
- data/app/views/resque/_workers.html.erb +115 -95
- data/lib/resque_ui/cap_recipes.rb +21 -1
- data/lib/resque_ui/overrides/resque/job.rb +66 -2
- data/lib/resque_ui/overrides/resque/worker.rb +72 -10
- data/lib/resque_ui/overrides/resque_status/job_with_status.rb +45 -1
- data/lib/resque_ui/overrides/resque_status/status.rb +5 -0
- data/rdoc/Resque/Job.html +68 -4
- data/rdoc/Resque/JobWithStatus.html +161 -7
- data/rdoc/Resque/Status.html +47 -5
- data/rdoc/Resque/Worker.html +313 -64
- data/rdoc/created.rid +8 -8
- data/rdoc/index.html +27 -7
- data/rdoc/lib/resque_ui/cap_rb.html +1 -1
- data/rdoc/lib/resque_ui/cap_recipes_rb.html +2 -2
- data/rdoc/lib/resque_ui/overrides/resque/job_rb.html +2 -2
- data/rdoc/lib/resque_ui/overrides/resque/resque_rb.html +1 -1
- data/rdoc/lib/resque_ui/overrides/resque/worker_rb.html +2 -2
- data/rdoc/lib/resque_ui/overrides/resque_scheduler/resque_scheduler_rb.html +1 -1
- data/rdoc/lib/resque_ui/overrides/resque_status/chained_job_with_status_rb.html +1 -1
- data/rdoc/lib/resque_ui/overrides/resque_status/job_with_status_rb.html +2 -2
- data/rdoc/lib/resque_ui/overrides/resque_status/status_rb.html +2 -2
- data/rdoc/lib/resque_ui_rb.html +2 -2
- data/resque_ui.gemspec +2 -2
- metadata +2 -2
data/rdoc/Resque/Status.html
CHANGED
@@ -75,6 +75,8 @@
|
|
75
75
|
|
76
76
|
<li><a href="#method-c-status_ids">::status_ids</a></li>
|
77
77
|
|
78
|
+
<li><a href="#method-i-paused-3F">#paused?</a></li>
|
79
|
+
|
78
80
|
</ul>
|
79
81
|
</div>
|
80
82
|
|
@@ -176,7 +178,7 @@ info about ranges</p>
|
|
176
178
|
|
177
179
|
<div class="method-source-code" id="clear-source">
|
178
180
|
<pre>
|
179
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line
|
181
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line 31</span>
|
180
182
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">clear</span>(<span class="ruby-identifier">range_start</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">range_end</span> = <span class="ruby-keyword">nil</span>)
|
181
183
|
<span class="ruby-identifier">status_ids</span>(<span class="ruby-identifier">range_start</span>, <span class="ruby-identifier">range_end</span>).<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span>
|
182
184
|
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">zrem</span>(<span class="ruby-identifier">set_key</span>, <span class="ruby-identifier">id</span>)
|
@@ -214,7 +216,7 @@ info about ranges</p>
|
|
214
216
|
|
215
217
|
<div class="method-source-code" id="counter-source">
|
216
218
|
<pre>
|
217
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line
|
219
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line 46</span>
|
218
220
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">counter</span>(<span class="ruby-identifier">counter</span>, <span class="ruby-identifier">uuid</span>)
|
219
221
|
<span class="ruby-identifier">redis</span>[<span class="ruby-identifier">counter_key</span>(<span class="ruby-identifier">counter</span>, <span class="ruby-identifier">uuid</span>)].<span class="ruby-identifier">to_i</span>
|
220
222
|
<span class="ruby-keyword">end</span></pre>
|
@@ -249,7 +251,7 @@ use a counter and call incr on it instead</p>
|
|
249
251
|
|
250
252
|
<div class="method-source-code" id="counter_key-source">
|
251
253
|
<pre>
|
252
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line
|
254
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line 42</span>
|
253
255
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">counter_key</span>(<span class="ruby-identifier">counter</span>, <span class="ruby-identifier">uuid</span>)
|
254
256
|
<span class="ruby-node">"#{counter}:#{uuid}"</span>
|
255
257
|
<span class="ruby-keyword">end</span></pre>
|
@@ -282,7 +284,7 @@ use a counter and call incr on it instead</p>
|
|
282
284
|
|
283
285
|
<div class="method-source-code" id="incr_counter-source">
|
284
286
|
<pre>
|
285
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line
|
287
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line 50</span>
|
286
288
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">incr_counter</span>(<span class="ruby-identifier">counter</span>, <span class="ruby-identifier">uuid</span>)
|
287
289
|
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">counter_key</span>(<span class="ruby-identifier">counter</span>, <span class="ruby-identifier">uuid</span>)
|
288
290
|
<span class="ruby-identifier">n</span> = <span class="ruby-identifier">redis</span>.<span class="ruby-identifier">incr</span>(<span class="ruby-identifier">key</span>)
|
@@ -322,7 +324,7 @@ use a counter and call incr on it instead</p>
|
|
322
324
|
|
323
325
|
<div class="method-source-code" id="status_ids-source">
|
324
326
|
<pre>
|
325
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line
|
327
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line 11</span>
|
326
328
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">status_ids</span>(<span class="ruby-identifier">range_start</span> = <span class="ruby-keyword">nil</span>, <span class="ruby-identifier">range_end</span> = <span class="ruby-keyword">nil</span>)
|
327
329
|
<span class="ruby-keyword">unless</span> <span class="ruby-identifier">range_end</span> <span class="ruby-operator">&&</span> <span class="ruby-identifier">range_start</span>
|
328
330
|
<span class="ruby-comment"># Because we want a reverse chronological order, we need to get a range starting</span>
|
@@ -352,6 +354,46 @@ use a counter and call incr on it instead</p>
|
|
352
354
|
|
353
355
|
</div><!-- public-class-method-details -->
|
354
356
|
|
357
|
+
<div id="public-instance-method-details" class="method-section section">
|
358
|
+
<h3 class="section-header">Public Instance Methods</h3>
|
359
|
+
|
360
|
+
|
361
|
+
<div id="paused-3F-method" class="method-detail ">
|
362
|
+
<a name="method-i-paused-3F"></a>
|
363
|
+
|
364
|
+
|
365
|
+
<div class="method-heading">
|
366
|
+
<span class="method-name">paused?</span><span
|
367
|
+
class="method-args">()</span>
|
368
|
+
<span class="method-click-advice">click to toggle source</span>
|
369
|
+
</div>
|
370
|
+
|
371
|
+
|
372
|
+
<div class="method-description">
|
373
|
+
|
374
|
+
<p>The STATUSES constant is frozen, so we’ll just manually add the paused?
|
375
|
+
method here</p>
|
376
|
+
|
377
|
+
|
378
|
+
|
379
|
+
<div class="method-source-code" id="paused-3F-source">
|
380
|
+
<pre>
|
381
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque_status/status.rb, line 5</span>
|
382
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">paused?</span>
|
383
|
+
<span class="ruby-keyword">self</span>[<span class="ruby-string">'status'</span>] <span class="ruby-operator">===</span> <span class="ruby-string">'paused'</span>
|
384
|
+
<span class="ruby-keyword">end</span></pre>
|
385
|
+
</div><!-- paused-3F-source -->
|
386
|
+
|
387
|
+
</div>
|
388
|
+
|
389
|
+
|
390
|
+
|
391
|
+
|
392
|
+
</div><!-- paused-3F-method -->
|
393
|
+
|
394
|
+
|
395
|
+
</div><!-- public-instance-method-details -->
|
396
|
+
|
355
397
|
</div><!-- 5Buntitled-5D -->
|
356
398
|
|
357
399
|
|
data/rdoc/Resque/Worker.html
CHANGED
@@ -71,13 +71,23 @@
|
|
71
71
|
|
72
72
|
<li><a href="#method-i-all_workers_in_pid_working">#all_workers_in_pid_working</a></li>
|
73
73
|
|
74
|
+
<li><a href="#method-i-continue">#continue</a></li>
|
75
|
+
|
74
76
|
<li><a href="#method-i-id">#id</a></li>
|
75
77
|
|
76
78
|
<li><a href="#method-i-ip">#ip</a></li>
|
77
79
|
|
78
80
|
<li><a href="#method-i-local_ip">#local_ip</a></li>
|
79
81
|
|
80
|
-
<li><a href="#method-i-
|
82
|
+
<li><a href="#method-i-pause">#pause</a></li>
|
83
|
+
|
84
|
+
<li><a href="#method-i-pause_key">#pause_key</a></li>
|
85
|
+
|
86
|
+
<li><a href="#method-i-pause_processing">#pause_processing</a></li>
|
87
|
+
|
88
|
+
<li><a href="#method-i-paused">#paused</a></li>
|
89
|
+
|
90
|
+
<li><a href="#method-i-paused-3F">#paused?</a></li>
|
81
91
|
|
82
92
|
<li><a href="#method-i-prune_dead_workers">#prune_dead_workers</a></li>
|
83
93
|
|
@@ -103,9 +113,11 @@
|
|
103
113
|
|
104
114
|
<li><a href="#method-i-to_s">#to_s</a></li>
|
105
115
|
|
106
|
-
<li><a href="#method-i-
|
116
|
+
<li><a href="#method-i-unpause_processing">#unpause_processing</a></li>
|
117
|
+
|
118
|
+
<li><a href="#method-i-unregister_worker">#unregister_worker</a></li>
|
107
119
|
|
108
|
-
<li><a href="#method-i-
|
120
|
+
<li><a href="#method-i-work">#work</a></li>
|
109
121
|
|
110
122
|
<li><a href="#method-i-workers_in_pid">#workers_in_pid</a></li>
|
111
123
|
|
@@ -209,7 +221,7 @@
|
|
209
221
|
|
210
222
|
<div class="method-source-code" id="start-source">
|
211
223
|
<pre>
|
212
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
224
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 234</span>
|
213
225
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">start</span>(<span class="ruby-identifier">ips</span>, <span class="ruby-identifier">queues</span>)
|
214
226
|
<span class="ruby-keyword">if</span> <span class="ruby-constant">Rails</span>.<span class="ruby-identifier">env</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/development|test/</span>
|
215
227
|
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">queues</span>) { <span class="ruby-operator">|</span><span class="ruby-identifier">queue</span><span class="ruby-operator">|</span> <span class="ruby-identifier">system</span>(<span class="ruby-node">"rake RAILS_ENV=#{Rails.env} QUEUE=#{queue} resque:work"</span>) }
|
@@ -247,7 +259,7 @@ latest redis gem.</p>
|
|
247
259
|
|
248
260
|
<div class="method-source-code" id="working-source">
|
249
261
|
<pre>
|
250
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
262
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 216</span>
|
251
263
|
<span class="ruby-keyword">def</span> <span class="ruby-keyword">self</span>.<span class="ruby-identifier">working</span>
|
252
264
|
<span class="ruby-identifier">names</span> = <span class="ruby-identifier">all</span>
|
253
265
|
<span class="ruby-keyword">return</span> [] <span class="ruby-keyword">unless</span> <span class="ruby-identifier">names</span>.<span class="ruby-identifier">any?</span>
|
@@ -291,7 +303,7 @@ latest redis gem.</p>
|
|
291
303
|
|
292
304
|
<div class="method-source-code" id="all_workers_in_pid_working-source">
|
293
305
|
<pre>
|
294
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
306
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 153</span>
|
295
307
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">all_workers_in_pid_working</span>
|
296
308
|
<span class="ruby-identifier">workers_in_pid</span>.<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span> (<span class="ruby-identifier">hash</span> = <span class="ruby-identifier">w</span>.<span class="ruby-identifier">processing</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">hash</span>.<span class="ruby-identifier">empty?</span> }
|
297
309
|
<span class="ruby-keyword">end</span></pre>
|
@@ -305,6 +317,43 @@ latest redis gem.</p>
|
|
305
317
|
</div><!-- all_workers_in_pid_working-method -->
|
306
318
|
|
307
319
|
|
320
|
+
<div id="continue-method" class="method-detail ">
|
321
|
+
<a name="method-i-continue"></a>
|
322
|
+
|
323
|
+
|
324
|
+
<div class="method-heading">
|
325
|
+
<span class="method-name">continue</span><span
|
326
|
+
class="method-args">()</span>
|
327
|
+
<span class="method-click-advice">click to toggle source</span>
|
328
|
+
</div>
|
329
|
+
|
330
|
+
|
331
|
+
<div class="method-description">
|
332
|
+
|
333
|
+
|
334
|
+
|
335
|
+
|
336
|
+
|
337
|
+
<div class="method-source-code" id="continue-source">
|
338
|
+
<pre>
|
339
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 265</span>
|
340
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">continue</span>
|
341
|
+
<span class="ruby-keyword">if</span> <span class="ruby-constant">Rails</span>.<span class="ruby-identifier">env</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/development|test/</span>
|
342
|
+
<span class="ruby-identifier">system</span>(<span class="ruby-node">"kill -CONT #{self.pid}"</span>)
|
343
|
+
<span class="ruby-keyword">else</span>
|
344
|
+
<span class="ruby-identifier">system</span>(<span class="ruby-node">"cd #{Rails.root}; #{ResqueUi::Cap.path} #{Rails.env} resque:continue_worker pid=#{self.pid} host=#{self.ip}"</span>)
|
345
|
+
<span class="ruby-keyword">end</span>
|
346
|
+
<span class="ruby-keyword">end</span></pre>
|
347
|
+
</div><!-- continue-source -->
|
348
|
+
|
349
|
+
</div>
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
|
354
|
+
</div><!-- continue-method -->
|
355
|
+
|
356
|
+
|
308
357
|
<div id="id-method" class="method-detail method-alias">
|
309
358
|
<a name="method-i-id"></a>
|
310
359
|
|
@@ -353,7 +402,7 @@ latest redis gem.</p>
|
|
353
402
|
|
354
403
|
<div class="method-source-code" id="ip-source">
|
355
404
|
<pre>
|
356
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
405
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 43</span>
|
357
406
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">ip</span>
|
358
407
|
<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">':'</span>).<span class="ruby-identifier">first</span>[<span class="ruby-regexp">/\b(?:\d{1,3}\.){3}\d{1,3}\b/</span>]
|
359
408
|
<span class="ruby-keyword">end</span></pre>
|
@@ -407,12 +456,12 @@ latest redis gem.</p>
|
|
407
456
|
</div><!-- local_ip-method -->
|
408
457
|
|
409
458
|
|
410
|
-
<div id="
|
411
|
-
<a name="method-i-
|
459
|
+
<div id="pause-method" class="method-detail ">
|
460
|
+
<a name="method-i-pause"></a>
|
412
461
|
|
413
462
|
|
414
463
|
<div class="method-heading">
|
415
|
-
<span class="method-name">
|
464
|
+
<span class="method-name">pause</span><span
|
416
465
|
class="method-args">()</span>
|
417
466
|
<span class="method-click-advice">click to toggle source</span>
|
418
467
|
</div>
|
@@ -424,20 +473,166 @@ latest redis gem.</p>
|
|
424
473
|
|
425
474
|
|
426
475
|
|
427
|
-
<div class="method-source-code" id="
|
476
|
+
<div class="method-source-code" id="pause-source">
|
477
|
+
<pre>
|
478
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 257</span>
|
479
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">pause</span>
|
480
|
+
<span class="ruby-keyword">if</span> <span class="ruby-constant">Rails</span>.<span class="ruby-identifier">env</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/development|test/</span>
|
481
|
+
<span class="ruby-identifier">system</span>(<span class="ruby-node">"kill -USR2 #{self.pid}"</span>)
|
482
|
+
<span class="ruby-keyword">else</span>
|
483
|
+
<span class="ruby-identifier">system</span>(<span class="ruby-node">"cd #{Rails.root}; #{ResqueUi::Cap.path} #{Rails.env} resque:pause_worker pid=#{self.pid} host=#{self.ip}"</span>)
|
484
|
+
<span class="ruby-keyword">end</span>
|
485
|
+
<span class="ruby-keyword">end</span></pre>
|
486
|
+
</div><!-- pause-source -->
|
487
|
+
|
488
|
+
</div>
|
489
|
+
|
490
|
+
|
491
|
+
|
492
|
+
|
493
|
+
</div><!-- pause-method -->
|
494
|
+
|
495
|
+
|
496
|
+
<div id="pause_key-method" class="method-detail ">
|
497
|
+
<a name="method-i-pause_key"></a>
|
498
|
+
|
499
|
+
|
500
|
+
<div class="method-heading">
|
501
|
+
<span class="method-name">pause_key</span><span
|
502
|
+
class="method-args">()</span>
|
503
|
+
<span class="method-click-advice">click to toggle source</span>
|
504
|
+
</div>
|
505
|
+
|
506
|
+
|
507
|
+
<div class="method-description">
|
508
|
+
|
509
|
+
<p>When the worker gets the -USR2 signal, <a
|
510
|
+
href="Worker.html#method-i-to_s">to_s</a> may give a different value for
|
511
|
+
the thread and queue portion</p>
|
512
|
+
|
513
|
+
|
514
|
+
|
515
|
+
<div class="method-source-code" id="pause_key-source">
|
428
516
|
<pre>
|
429
517
|
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 25</span>
|
430
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">
|
431
|
-
<span class="ruby-identifier">
|
518
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">pause_key</span>
|
519
|
+
<span class="ruby-identifier">key</span> = <span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">':'</span>)
|
520
|
+
<span class="ruby-node">"worker:#{key.first}:#{key.second}:all_workers:paused"</span>
|
521
|
+
<span class="ruby-keyword">end</span></pre>
|
522
|
+
</div><!-- pause_key-source -->
|
523
|
+
|
524
|
+
</div>
|
525
|
+
|
526
|
+
|
527
|
+
|
528
|
+
|
529
|
+
</div><!-- pause_key-method -->
|
530
|
+
|
531
|
+
|
532
|
+
<div id="pause_processing-method" class="method-detail ">
|
533
|
+
<a name="method-i-pause_processing"></a>
|
534
|
+
|
535
|
+
|
536
|
+
<div class="method-heading">
|
537
|
+
<span class="method-name">pause_processing</span><span
|
538
|
+
class="method-args">()</span>
|
539
|
+
<span class="method-click-advice">click to toggle source</span>
|
540
|
+
</div>
|
541
|
+
|
542
|
+
|
543
|
+
<div class="method-description">
|
544
|
+
|
545
|
+
<pre>Stop processing jobs after the current one has completed (if we're
|
546
|
+
currently running one).</pre>
|
547
|
+
|
548
|
+
<p>OVERRIDE to set a redis key so UI knows it’s paused too</p>
|
549
|
+
|
550
|
+
<pre>Would prefer to call super but get no superclass method error</pre>
|
551
|
+
|
552
|
+
|
553
|
+
|
554
|
+
<div class="method-source-code" id="pause_processing-source">
|
555
|
+
<pre>
|
556
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 95</span>
|
557
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">pause_processing</span>
|
558
|
+
<span class="ruby-identifier">log</span> <span class="ruby-string">"USR2 received; pausing job processing"</span>
|
559
|
+
<span class="ruby-ivar">@paused</span> = <span class="ruby-keyword">true</span>
|
560
|
+
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">set</span>(<span class="ruby-identifier">pause_key</span>, <span class="ruby-constant">Time</span>.<span class="ruby-identifier">now</span>.<span class="ruby-identifier">to_s</span>)
|
561
|
+
<span class="ruby-keyword">end</span></pre>
|
562
|
+
</div><!-- pause_processing-source -->
|
563
|
+
|
564
|
+
</div>
|
565
|
+
|
566
|
+
|
567
|
+
|
568
|
+
|
569
|
+
</div><!-- pause_processing-method -->
|
570
|
+
|
571
|
+
|
572
|
+
<div id="paused-method" class="method-detail ">
|
573
|
+
<a name="method-i-paused"></a>
|
574
|
+
|
575
|
+
|
576
|
+
<div class="method-heading">
|
577
|
+
<span class="method-name">paused</span><span
|
578
|
+
class="method-args">()</span>
|
579
|
+
<span class="method-click-advice">click to toggle source</span>
|
580
|
+
</div>
|
581
|
+
|
582
|
+
|
583
|
+
<div class="method-description">
|
584
|
+
|
585
|
+
|
586
|
+
|
587
|
+
|
588
|
+
|
589
|
+
<div class="method-source-code" id="paused-source">
|
590
|
+
<pre>
|
591
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 81</span>
|
592
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">paused</span>
|
593
|
+
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">get</span> <span class="ruby-identifier">pause_key</span>
|
432
594
|
<span class="ruby-keyword">end</span></pre>
|
433
|
-
</div><!--
|
595
|
+
</div><!-- paused-source -->
|
434
596
|
|
435
597
|
</div>
|
436
598
|
|
437
599
|
|
438
600
|
|
439
601
|
|
440
|
-
</div><!--
|
602
|
+
</div><!-- paused-method -->
|
603
|
+
|
604
|
+
|
605
|
+
<div id="paused-3F-method" class="method-detail ">
|
606
|
+
<a name="method-i-paused-3F"></a>
|
607
|
+
|
608
|
+
|
609
|
+
<div class="method-heading">
|
610
|
+
<span class="method-name">paused?</span><span
|
611
|
+
class="method-args">()</span>
|
612
|
+
<span class="method-click-advice">click to toggle source</span>
|
613
|
+
</div>
|
614
|
+
|
615
|
+
|
616
|
+
<div class="method-description">
|
617
|
+
|
618
|
+
<p>are we paused? OVERRIDE so UI can tell if we’re paused</p>
|
619
|
+
|
620
|
+
|
621
|
+
|
622
|
+
<div class="method-source-code" id="paused-3F-source">
|
623
|
+
<pre>
|
624
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 87</span>
|
625
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">paused?</span>
|
626
|
+
<span class="ruby-ivar">@paused</span> <span class="ruby-operator">||</span> <span class="ruby-identifier">paused</span>.<span class="ruby-identifier">present?</span>
|
627
|
+
<span class="ruby-keyword">end</span></pre>
|
628
|
+
</div><!-- paused-3F-source -->
|
629
|
+
|
630
|
+
</div>
|
631
|
+
|
632
|
+
|
633
|
+
|
634
|
+
|
635
|
+
</div><!-- paused-3F-method -->
|
441
636
|
|
442
637
|
|
443
638
|
<div id="prune_dead_workers-method" class="method-detail ">
|
@@ -468,7 +663,7 @@ determine if Redis is old and clean it up a bit.</p>
|
|
468
663
|
|
469
664
|
<div class="method-source-code" id="prune_dead_workers-source">
|
470
665
|
<pre>
|
471
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
666
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 120</span>
|
472
667
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">prune_dead_workers</span>
|
473
668
|
<span class="ruby-constant">Worker</span>.<span class="ruby-identifier">all</span>.<span class="ruby-identifier">each</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">worker</span><span class="ruby-operator">|</span>
|
474
669
|
<span class="ruby-identifier">host</span>, <span class="ruby-identifier">pid</span>, <span class="ruby-identifier">thread</span>, <span class="ruby-identifier">queues</span> = <span class="ruby-identifier">worker</span>.<span class="ruby-identifier">id</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">':'</span>)
|
@@ -507,7 +702,7 @@ determine if Redis is old and clean it up a bit.</p>
|
|
507
702
|
|
508
703
|
<div class="method-source-code" id="queue-source">
|
509
704
|
<pre>
|
510
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
705
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 35</span>
|
511
706
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">queue</span>
|
512
707
|
<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">':'</span>).<span class="ruby-identifier">last</span>
|
513
708
|
<span class="ruby-keyword">end</span></pre>
|
@@ -540,7 +735,7 @@ determine if Redis is old and clean it up a bit.</p>
|
|
540
735
|
|
541
736
|
<div class="method-source-code" id="queues-source">
|
542
737
|
<pre>
|
543
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
738
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 52</span>
|
544
739
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">queues</span>
|
545
740
|
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-value">:queues</span>] <span class="ruby-operator">==</span> <span class="ruby-string">"*"</span> <span class="ruby-operator">?</span> <span class="ruby-constant">Resque</span>.<span class="ruby-identifier">queues</span>.<span class="ruby-identifier">sort</span> <span class="ruby-operator">:</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span>[<span class="ruby-value">:queues</span>].<span class="ruby-identifier">split</span>(<span class="ruby-string">','</span>)
|
546
741
|
<span class="ruby-keyword">end</span></pre>
|
@@ -573,7 +768,7 @@ determine if Redis is old and clean it up a bit.</p>
|
|
573
768
|
|
574
769
|
<div class="method-source-code" id="queues_in_pid-source">
|
575
770
|
<pre>
|
576
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
771
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 47</span>
|
577
772
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">queues_in_pid</span>
|
578
773
|
<span class="ruby-identifier">workers_in_pid</span>.<span class="ruby-identifier">collect</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">w</span><span class="ruby-operator">|</span> <span class="ruby-identifier">w</span>.<span class="ruby-identifier">queue</span> }
|
579
774
|
<span class="ruby-keyword">end</span></pre>
|
@@ -606,7 +801,7 @@ determine if Redis is old and clean it up a bit.</p>
|
|
606
801
|
|
607
802
|
<div class="method-source-code" id="quit-source">
|
608
803
|
<pre>
|
609
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
804
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 242</span>
|
610
805
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">quit</span>
|
611
806
|
<span class="ruby-keyword">if</span> <span class="ruby-constant">Rails</span>.<span class="ruby-identifier">env</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/development|test/</span>
|
612
807
|
<span class="ruby-keyword">if</span> <span class="ruby-constant">RUBY_PLATFORM</span> <span class="ruby-operator">=~</span> <span class="ruby-regexp">/java/</span>
|
@@ -650,7 +845,7 @@ determine if Redis is old and clean it up a bit.</p>
|
|
650
845
|
|
651
846
|
<div class="method-source-code" id="restart-source">
|
652
847
|
<pre>
|
653
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
848
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 273</span>
|
654
849
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">restart</span>
|
655
850
|
<span class="ruby-identifier">queues</span> = <span class="ruby-keyword">self</span>.<span class="ruby-identifier">queues_in_pid</span>.<span class="ruby-identifier">join</span>(<span class="ruby-string">'#'</span>)
|
656
851
|
<span class="ruby-identifier">quit</span>
|
@@ -688,7 +883,7 @@ current job.</pre>
|
|
688
883
|
|
689
884
|
<div class="method-source-code" id="shutdown-source">
|
690
885
|
<pre>
|
691
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
886
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 75</span>
|
692
887
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">shutdown</span>
|
693
888
|
<span class="ruby-identifier">log</span> <span class="ruby-string">'Exiting...'</span>
|
694
889
|
<span class="ruby-constant">Thread</span>.<span class="ruby-identifier">list</span>.<span class="ruby-identifier">each</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">t</span><span class="ruby-operator">|</span> <span class="ruby-identifier">t</span>[<span class="ruby-value">:shutdown</span>] = <span class="ruby-keyword">true</span> }
|
@@ -725,7 +920,7 @@ current job.</pre>
|
|
725
920
|
|
726
921
|
<div class="method-source-code" id="startup-source">
|
727
922
|
<pre>
|
728
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
923
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 58</span>
|
729
924
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">startup</span>
|
730
925
|
<span class="ruby-identifier">enable_gc_optimizations</span>
|
731
926
|
<span class="ruby-keyword">if</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">current</span> <span class="ruby-operator">==</span> <span class="ruby-constant">Thread</span>.<span class="ruby-identifier">main</span>
|
@@ -768,7 +963,7 @@ current job.</pre>
|
|
768
963
|
|
769
964
|
<div class="method-source-code" id="status-source">
|
770
965
|
<pre>
|
771
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
966
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 230</span>
|
772
967
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">status</span>
|
773
968
|
<span class="ruby-identifier">job</span>[<span class="ruby-string">'status'</span>]
|
774
969
|
<span class="ruby-keyword">end</span></pre>
|
@@ -801,7 +996,7 @@ current job.</pre>
|
|
801
996
|
|
802
997
|
<div class="method-source-code" id="status-3D-source">
|
803
998
|
<pre>
|
804
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
999
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 225</span>
|
805
1000
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">status=</span>(<span class="ruby-identifier">status</span>)
|
806
1001
|
<span class="ruby-identifier">data</span> = <span class="ruby-identifier">encode</span>(<span class="ruby-identifier">job</span>.<span class="ruby-identifier">merge</span>(<span class="ruby-string">'status'</span> =<span class="ruby-operator">></span> <span class="ruby-identifier">status</span>))
|
807
1002
|
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">set</span>(<span class="ruby-node">"worker:#{self}"</span>, <span class="ruby-identifier">data</span>)
|
@@ -835,7 +1030,7 @@ current job.</pre>
|
|
835
1030
|
|
836
1031
|
<div class="method-source-code" id="thread-source">
|
837
1032
|
<pre>
|
838
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
1033
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 31</span>
|
839
1034
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">thread</span>
|
840
1035
|
<span class="ruby-identifier">to_s</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">':'</span>).<span class="ruby-identifier">third</span>
|
841
1036
|
<span class="ruby-keyword">end</span></pre>
|
@@ -887,6 +1082,96 @@ Can be used with `Worker.find`.</p>
|
|
887
1082
|
</div><!-- to_s-method -->
|
888
1083
|
|
889
1084
|
|
1085
|
+
<div id="unpause_processing-method" class="method-detail ">
|
1086
|
+
<a name="method-i-unpause_processing"></a>
|
1087
|
+
|
1088
|
+
|
1089
|
+
<div class="method-heading">
|
1090
|
+
<span class="method-name">unpause_processing</span><span
|
1091
|
+
class="method-args">()</span>
|
1092
|
+
<span class="method-click-advice">click to toggle source</span>
|
1093
|
+
</div>
|
1094
|
+
|
1095
|
+
|
1096
|
+
<div class="method-description">
|
1097
|
+
|
1098
|
+
<pre>Start processing jobs again after a pause</pre>
|
1099
|
+
|
1100
|
+
<p>OVERRIDE to set remove redis key so UI knows it’s unpaused too</p>
|
1101
|
+
|
1102
|
+
<pre>Would prefer to call super but get no superclass method error</pre>
|
1103
|
+
|
1104
|
+
|
1105
|
+
|
1106
|
+
<div class="method-source-code" id="unpause_processing-source">
|
1107
|
+
<pre>
|
1108
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 104</span>
|
1109
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">unpause_processing</span>
|
1110
|
+
<span class="ruby-identifier">log</span> <span class="ruby-string">"CONT received; resuming job processing"</span>
|
1111
|
+
<span class="ruby-ivar">@paused</span> = <span class="ruby-keyword">false</span>
|
1112
|
+
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">del</span>(<span class="ruby-identifier">pause_key</span>)
|
1113
|
+
<span class="ruby-keyword">end</span></pre>
|
1114
|
+
</div><!-- unpause_processing-source -->
|
1115
|
+
|
1116
|
+
</div>
|
1117
|
+
|
1118
|
+
|
1119
|
+
|
1120
|
+
|
1121
|
+
</div><!-- unpause_processing-method -->
|
1122
|
+
|
1123
|
+
|
1124
|
+
<div id="unregister_worker-method" class="method-detail ">
|
1125
|
+
<a name="method-i-unregister_worker"></a>
|
1126
|
+
|
1127
|
+
|
1128
|
+
<div class="method-heading">
|
1129
|
+
<span class="method-name">unregister_worker</span><span
|
1130
|
+
class="method-args">()</span>
|
1131
|
+
<span class="method-click-advice">click to toggle source</span>
|
1132
|
+
</div>
|
1133
|
+
|
1134
|
+
|
1135
|
+
<div class="method-description">
|
1136
|
+
|
1137
|
+
<p>Unregisters ourself as a worker. Useful when shutting down. OVERRIDE to
|
1138
|
+
also remove the pause key Would prefer to call super but get no superclass
|
1139
|
+
method error</p>
|
1140
|
+
|
1141
|
+
|
1142
|
+
|
1143
|
+
<div class="method-source-code" id="unregister_worker-source">
|
1144
|
+
<pre>
|
1145
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 133</span>
|
1146
|
+
<span class="ruby-keyword">def</span> <span class="ruby-identifier">unregister_worker</span>
|
1147
|
+
<span class="ruby-comment"># If we're still processing a job, make sure it gets logged as a</span>
|
1148
|
+
<span class="ruby-comment"># failure.</span>
|
1149
|
+
<span class="ruby-keyword">if</span> (<span class="ruby-identifier">hash</span> = <span class="ruby-identifier">processing</span>) <span class="ruby-operator">&&</span> <span class="ruby-operator">!</span><span class="ruby-identifier">hash</span>.<span class="ruby-identifier">empty?</span>
|
1150
|
+
<span class="ruby-identifier">job</span> = <span class="ruby-constant">Job</span>.<span class="ruby-identifier">new</span>(<span class="ruby-identifier">hash</span>[<span class="ruby-string">'queue'</span>], <span class="ruby-identifier">hash</span>[<span class="ruby-string">'payload'</span>])
|
1151
|
+
<span class="ruby-comment"># Ensure the proper worker is attached to this job, even if</span>
|
1152
|
+
<span class="ruby-comment"># it's not the precise instance that died.</span>
|
1153
|
+
<span class="ruby-identifier">job</span>.<span class="ruby-identifier">worker</span> = <span class="ruby-keyword">self</span>
|
1154
|
+
<span class="ruby-identifier">job</span>.<span class="ruby-identifier">fail</span>(<span class="ruby-constant">DirtyExit</span>.<span class="ruby-identifier">new</span>)
|
1155
|
+
<span class="ruby-keyword">end</span>
|
1156
|
+
|
1157
|
+
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">srem</span>(<span class="ruby-value">:workers</span>, <span class="ruby-keyword">self</span>)
|
1158
|
+
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">del</span>(<span class="ruby-node">"worker:#{self}"</span>)
|
1159
|
+
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">del</span>(<span class="ruby-node">"worker:#{self}:started"</span>)
|
1160
|
+
<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">del</span>(<span class="ruby-identifier">pause_key</span>)
|
1161
|
+
|
1162
|
+
<span class="ruby-constant">Stat</span>.<span class="ruby-identifier">clear</span>(<span class="ruby-node">"processed:#{self}"</span>)
|
1163
|
+
<span class="ruby-constant">Stat</span>.<span class="ruby-identifier">clear</span>(<span class="ruby-node">"failed:#{self}"</span>)
|
1164
|
+
<span class="ruby-keyword">end</span></pre>
|
1165
|
+
</div><!-- unregister_worker-source -->
|
1166
|
+
|
1167
|
+
</div>
|
1168
|
+
|
1169
|
+
|
1170
|
+
|
1171
|
+
|
1172
|
+
</div><!-- unregister_worker-method -->
|
1173
|
+
|
1174
|
+
|
890
1175
|
<div id="work-method" class="method-detail ">
|
891
1176
|
<a name="method-i-work"></a>
|
892
1177
|
|
@@ -923,7 +1208,7 @@ has completed processing. Useful for testing.</pre>
|
|
923
1208
|
|
924
1209
|
<div class="method-source-code" id="work-source">
|
925
1210
|
<pre>
|
926
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
1211
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 174</span>
|
927
1212
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">work</span>(<span class="ruby-identifier">interval</span> = <span class="ruby-value">5</span>, &<span class="ruby-identifier">block</span>)
|
928
1213
|
<span class="ruby-identifier">$0</span> = <span class="ruby-string">"resque: Starting"</span>
|
929
1214
|
<span class="ruby-identifier">startup</span>
|
@@ -974,42 +1259,6 @@ has completed processing. Useful for testing.</pre>
|
|
974
1259
|
</div><!-- work-method -->
|
975
1260
|
|
976
1261
|
|
977
|
-
<div id="worker_pids-method" class="method-detail ">
|
978
|
-
<a name="method-i-worker_pids"></a>
|
979
|
-
|
980
|
-
|
981
|
-
<div class="method-heading">
|
982
|
-
<span class="method-name">worker_pids</span><span
|
983
|
-
class="method-args">()</span>
|
984
|
-
<span class="method-click-advice">click to toggle source</span>
|
985
|
-
</div>
|
986
|
-
|
987
|
-
|
988
|
-
<div class="method-description">
|
989
|
-
|
990
|
-
<p>Returns an array of string pids of all the other workers on this machine.
|
991
|
-
Useful when pruning dead workers on startup.</p>
|
992
|
-
|
993
|
-
|
994
|
-
|
995
|
-
<div class="method-source-code" id="worker_pids-source">
|
996
|
-
<pre>
|
997
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 173</span>
|
998
|
-
<span class="ruby-keyword">def</span> <span class="ruby-identifier">worker_pids</span>
|
999
|
-
<span class="ruby-value">`ps -A -o pid,command | grep [r]esque`</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">"\n"</span>).<span class="ruby-identifier">map</span> <span class="ruby-keyword">do</span> <span class="ruby-operator">|</span><span class="ruby-identifier">line</span><span class="ruby-operator">|</span>
|
1000
|
-
<span class="ruby-identifier">line</span>.<span class="ruby-identifier">split</span>(<span class="ruby-string">' '</span>)[<span class="ruby-value">0</span>]
|
1001
|
-
<span class="ruby-keyword">end</span>
|
1002
|
-
<span class="ruby-keyword">end</span></pre>
|
1003
|
-
</div><!-- worker_pids-source -->
|
1004
|
-
|
1005
|
-
</div>
|
1006
|
-
|
1007
|
-
|
1008
|
-
|
1009
|
-
|
1010
|
-
</div><!-- worker_pids-method -->
|
1011
|
-
|
1012
|
-
|
1013
1262
|
<div id="workers_in_pid-method" class="method-detail ">
|
1014
1263
|
<a name="method-i-workers_in_pid"></a>
|
1015
1264
|
|
@@ -1029,7 +1278,7 @@ Useful when pruning dead workers on startup.</p>
|
|
1029
1278
|
|
1030
1279
|
<div class="method-source-code" id="workers_in_pid-source">
|
1031
1280
|
<pre>
|
1032
|
-
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line
|
1281
|
+
<span class="ruby-comment"># File lib/resque_ui/overrides/resque/worker.rb, line 39</span>
|
1033
1282
|
<span class="ruby-keyword">def</span> <span class="ruby-identifier">workers_in_pid</span>
|
1034
1283
|
<span class="ruby-constant">Array</span>(<span class="ruby-identifier">redis</span>.<span class="ruby-identifier">smembers</span>(<span class="ruby-value">:workers</span>)).<span class="ruby-identifier">select</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span> <span class="ruby-identifier">id</span> <span class="ruby-operator">=~</span> <span class="ruby-node">/\(#{ip}\):#{pid}/</span> }.<span class="ruby-identifier">map</span> { <span class="ruby-operator">|</span><span class="ruby-identifier">id</span><span class="ruby-operator">|</span> <span class="ruby-constant">Resque</span><span class="ruby-operator">::</span><span class="ruby-constant">Worker</span>.<span class="ruby-identifier">find</span>(<span class="ruby-identifier">id</span>) }.<span class="ruby-identifier">compact</span>
|
1035
1284
|
<span class="ruby-keyword">end</span></pre>
|