resque-job-killer 0.1.3 → 0.1.4

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: bc611acc201bf87ac89318ba7e0cf7962601a91c09fe579611f6ab5e0cb9f80e
4
- data.tar.gz: fe7e325047c6fa289ecc409a87c82abfb0341de95649bb83b4f38cd475f04798
3
+ metadata.gz: 1f32a6868abf76e1682ebcfbfd8174032d01d96b8116898a8ba805ad3350ed48
4
+ data.tar.gz: 248e5c7b92f58ab2a52b4c3c04a27cb5a126d4577e4980fe77509f4468c0b91a
5
5
  SHA512:
6
- metadata.gz: 75cdb71c702fc8c7a5d0b50c3fa365e7c0d3030d9febc1ab3fb511d7cacd45f1afc817dd980fedd3a05e1eeab6c9104f1a5a174d9bf88aa33f70239239641992
7
- data.tar.gz: 2bbc68a7ba648aafc37887f542b38b03d0f071a9183ffdbccd00ac048e0ad31d888d4c45e420728827c431b3717f963a66bc25b4cfb33798bc39c943b8f5c5fb
6
+ metadata.gz: b5051390c2971a4030d536edfbeacb8eaee6ef1cc2191079f09924b8cbe5c8fa7e917e458f713abd869bf774ecd1c2fb7b517059cae78b0471c32007c4300c7b
7
+ data.tar.gz: 0cba2b335e0ebd78d8640a78c4d500c662e668e504e8d8314ebb59912cb11d964b8532ffe763801df10f443d4d0b774384f6e7625b40bafe4742c3aa70691060
@@ -0,0 +1,46 @@
1
+ module Resque
2
+ module Plugins
3
+ module JobKiller
4
+
5
+ MAX_HISTORY_SIZE = 500
6
+ HISTORY_SET_NAME = "resque_history"
7
+
8
+ def maximum_history_size
9
+ @max_history ||= MAX_HISTORY_SIZE
10
+ end
11
+
12
+ def on_failure_history(exception, *args)
13
+ Resque.redis.lpush(HISTORY_SET_NAME, {:class => "#{self}",
14
+ :time => Time.now.strftime("%Y-%m-%d %H:%M:%S %z"),
15
+ :args => args,
16
+ :error => exception.message
17
+ }.to_json)
18
+
19
+ if Resque.redis.llen(HISTORY_SET_NAME) > maximum_history_size
20
+ Resque.redis.rpop(HISTORY_SET_NAME)
21
+ end
22
+
23
+ end
24
+
25
+
26
+ def before_perform_history(*args)
27
+ @start_time = Time.now
28
+ end
29
+
30
+ def after_perform_history(*args)
31
+ elapsed_seconds = (Time.now - @start_time).to_i
32
+ Resque.redis.lpush(HISTORY_SET_NAME, {:class => "#{self}",
33
+ :args => args,
34
+ :time => Time.now.strftime("%Y-%m-%d %H:%M:%S %z"),
35
+ :execution =>elapsed_seconds
36
+ }.to_json)
37
+
38
+ if Resque.redis.llen(HISTORY_SET_NAME) > maximum_history_size
39
+ Resque.redis.rpop(HISTORY_SET_NAME)
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+ end
46
+ end
@@ -0,0 +1,62 @@
1
+ <% size = resque_history_total_jobs %>
2
+ <% start = params[:start].to_i %>
3
+ <% history = Resque.redis.lrange(resque_historyE, start, start + 20)%>
4
+
5
+ <h1 class='wi'>Job history</h1>
6
+
7
+ <% if size > 0 %>
8
+ <form method="POST" action="<%=u 'history/clear'%>" class='clear-delayed'>
9
+ <input type='submit' name='' value='Clear History' />
10
+ </form>
11
+ <% end %>
12
+
13
+ <p class='intro'>Showing <%= start %> to
14
+ <% if size > 20 %>
15
+ <%= start + 20 %> of <b><%= size %></b>
16
+ <% else %>
17
+ <%= size %>
18
+ <% end %>jobs</p>
19
+
20
+ <div id="main">
21
+ <%= erb File.read(ResqueHistory::Server.erb_path('navigation.erb')), {},
22
+ :start => params[:start].to_i, :size => size %>
23
+
24
+ <table>
25
+ <tr>
26
+ <th>Job</th>
27
+ <th>Arguments</th>
28
+ <th>Time</th>
29
+ <th>Execution</th>
30
+ </tr>
31
+ <% history.each do |history| %>
32
+ <% j = JSON.parse(history, :symbolize_names => true, :symbolize_keys => true) %>
33
+ <tr class='<%= j[:error].nil? ? "" : "failure" %>' >
34
+ <td class='queue'><%= j[:class] %></td>
35
+ <td class='argument'><pre><%= j[:args] ? show_args(j[:args]) : '' %></pre></td>
36
+ <td class='time'><%= j[:time] %></td>
37
+ <td class='execution'><%= format_execution(j[:execution]) %></td>
38
+ </tr>
39
+ <% end %>
40
+ </table>
41
+
42
+ <%= erb File.read(ResqueHistory::Server.erb_path('navigation.erb')), {},
43
+ :start => params[:start].to_i, :size => size %>
44
+ </div>
45
+
46
+ <style type="text/css">
47
+ #main table tr.failure td {
48
+ background: #ffecec;
49
+ border-top: 2px solid #d37474;
50
+ font-size: 90%;
51
+ color: #d37474;
52
+ }
53
+
54
+ .argument {
55
+ max-width: 250px;
56
+ word-wrap: break-word;
57
+ }
58
+
59
+ #main table tr.failure td a {
60
+ color: #d37474;
61
+ }
62
+ </style>
@@ -0,0 +1,2 @@
1
+ require 'resque'
2
+ require File.expand_path(File.join('resque-job-killer', 'plugins', 'job_killer'), File.dirname(__FILE__))
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: resque-job-killer
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - fooooxmr
@@ -16,7 +16,10 @@ executables: []
16
16
  extensions: []
17
17
  extra_rdoc_files: []
18
18
  files:
19
+ - lib/resque-job-killer.rb
20
+ - lib/resque-job-killer/plugins/job_killer.rb
19
21
  - lib/resque-job-killer/server.rb
22
+ - lib/resque-job-killer/server/views/job_killer.erb
20
23
  homepage:
21
24
  licenses: []
22
25
  metadata: {}