mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
merge master
This commit is contained in:
commit
4e14845d66
10 changed files with 47 additions and 14 deletions
10
Changes.md
10
Changes.md
|
@ -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
|
||||
-----------
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -93,7 +93,7 @@ case "$1" in
|
|||
fi
|
||||
;;
|
||||
*)
|
||||
echo "Usage: $0 {start|stop|status}"
|
||||
echo "Usage: $0 {start|stop|restart|status}"
|
||||
exit 0
|
||||
;;
|
||||
esac
|
||||
|
|
|
@ -236,8 +236,10 @@ module Sidekiq
|
|||
|
||||
def add_to_queue
|
||||
Sidekiq.redis do |conn|
|
||||
results = conn.zrangebyscore('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 @@ module Sidekiq
|
|||
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)
|
||||
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
|
||||
|
|
|
@ -46,9 +46,13 @@ module Sidekiq
|
|||
self_read, self_write = IO.pipe
|
||||
|
||||
%w(INT TERM USR1 USR2 TTIN).each do |sig|
|
||||
begin
|
||||
trap sig do
|
||||
self_write.puts(sig)
|
||||
end
|
||||
rescue ArgumentError
|
||||
puts "Signal #{sig} not supported"
|
||||
end
|
||||
end
|
||||
|
||||
redis {} # noop to connect redis and print info
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Sidekiq
|
||||
VERSION = "2.17.5"
|
||||
VERSION = "2.17.7"
|
||||
end
|
||||
|
|
|
@ -39,7 +39,7 @@ module Sidekiq
|
|||
end
|
||||
|
||||
get "/workers" do
|
||||
erb :index
|
||||
erb :workers
|
||||
end
|
||||
|
||||
get "/queues" do
|
||||
|
|
|
@ -47,13 +47,28 @@ module Sidekiq
|
|||
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
|
||||
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Add table
Reference in a new issue