Permalink
Browse files

merge master

  • Loading branch information...
mperham committed Feb 22, 2014
2 parents 7d2b387 + 939006e commit 4e14845d66c14548bb2b3ce61f8c74ee698213d8
View
@@ -20,6 +20,16 @@ Please see [Upgrading.md](Upgrading.md) for upgrade notes.
- Remove deprecated Sidekiq::Client.registered\_\* APIs
- Remove deprecated support for the old Sidekiq::Worker#retries\_exhausted method.
+2.17.7
+-----------
+
+- Auto-prune jobs older than one hour from the Workers page [#1508]
+
+2.17.6
+-----------
+
+- Fix capistrano integration due to missing pidfile. [#1490]
+
2.17.5
-----------
View
@@ -12,7 +12,7 @@ class Sidekiqctl
@timeout = timeout
done('No pidfile given', :error) if !pidfile
- done("Pidfile #{pidfile} does not exist", :error) if !File.exist?(pidfile)
+ done("Pidfile #{pidfile} does not exist", :warn) if !File.exist?(pidfile)
done('Invalid pidfile content', :error) if pid == 0
fetch_process
@@ -40,7 +40,7 @@ class Sidekiqctl
end
def pid
- File.read(pidfile).to_i
+ @pid ||= File.read(pidfile).to_i
end
def quiet
View
@@ -93,7 +93,7 @@ case "$1" in
fi
;;
*)
- echo "Usage: $0 {start|stop|status}"
+ echo "Usage: $0 {start|stop|restart|status}"
exit 0
;;
esac
View
@@ -236,8 +236,10 @@ def reschedule(at)
def add_to_queue
Sidekiq.redis do |conn|
- results = conn.zrangebyscore('schedule', score, score)
- conn.zremrangebyscore('schedule', score, score)
+ results = conn.multi do
+ conn.zrangebyscore('schedule', score, score)
+ conn.zremrangebyscore('schedule', score, score)
+ end.first
results.map do |message|
msg = Sidekiq.load_json(message)
Sidekiq::Client.push(msg)
@@ -248,8 +250,10 @@ def add_to_queue
def retry
raise "Retry not available on jobs which have not failed" unless item["failed_at"]
Sidekiq.redis do |conn|
- results = conn.zrangebyscore(parent.name, score, score)
- conn.zremrangebyscore(parent.name, score, score)
+ results = conn.multi do
+ conn.zrangebyscore(parent.name, score, score)
+ conn.zremrangebyscore(parent.name, score, score)
+ end.first
results.map do |message|
msg = Sidekiq.load_json(message)
msg['retry_count'] = msg['retry_count'] - 1
View
@@ -46,8 +46,12 @@ def run
self_read, self_write = IO.pipe
%w(INT TERM USR1 USR2 TTIN).each do |sig|
- trap sig do
- self_write.puts(sig)
+ begin
+ trap sig do
+ self_write.puts(sig)
+ end
+ rescue ArgumentError
+ puts "Signal #{sig} not supported"
end
end
View
@@ -1,3 +1,3 @@
module Sidekiq
- VERSION = "2.17.5"
+ VERSION = "2.17.7"
end
View
@@ -39,7 +39,7 @@ def custom_tabs
end
get "/workers" do
- erb :index
+ erb :workers
end
get "/queues" do
View
@@ -47,13 +47,28 @@ def workers_size
end
end
+ MAX_JOB_DURATION = 60*60
+
def workers
@workers ||= begin
to_rem = []
workers = Sidekiq.redis do |conn|
conn.smembers('workers').map do |w|
msg = conn.get("worker:#{w}")
- msg ? [w, Sidekiq.load_json(msg)] : (to_rem << w; nil)
+ if !msg
+ to_rem << w
+ nil
+ else
+ m = Sidekiq.load_json(msg)
+ run_at = Time.at(m['run_at'])
+ # prune jobs older than one hour
+ if run_at < (Time.now - MAX_JOB_DURATION)
+ to_rem << w
+ nil
+ else
+ [w, m, run_at]
+ end
+ end
end.compact.sort { |x| x[1] ? -1 : 1 }
end
View
@@ -6,7 +6,7 @@
<th><%= t('Arguments') %></th>
<th><%= t('Started') %></th>
</thead>
- <% workers.each_with_index do |(worker, msg), index| %>
+ <% workers.each_with_index do |(worker, msg, run_at), index| %>
<tr>
<td><%= worker %></td>
<td>
@@ -16,7 +16,7 @@
<td>
<div class="args"><%= display_args(msg['payload']['args']) %></div>
</td>
- <td><%= relative_time(msg['run_at'].is_a?(Numeric) ? Time.at(msg['run_at']) : Time.parse(msg['run_at'])) %></td>
+ <td><%= relative_time(run_at) %></td>
</tr>
<% end %>
</table>
File renamed without changes.

0 comments on commit 4e14845

Please sign in to comment.