1
0
Fork 0
mirror of https://github.com/mperham/sidekiq.git synced 2022-11-09 13:52:34 -05:00

Send the full process info on each heartbeat so transient timeouts don't lead to a process disappearing in Busy, fixes #1884

This commit is contained in:
Mike Perham 2014-08-07 21:03:34 -07:00
parent 104343615a
commit 5de3ef4353
3 changed files with 14 additions and 14 deletions

View file

@ -1,6 +1,8 @@
3.2.2 3.2.2
----------- -----------
- Fix issue which could cause Sidekiq workers to disappear from the Busy
tab while still being active [#1884]
- Add "Back to App" button in Web UI. You can set the button link via - Add "Back to App" button in Web UI. You can set the button link via
`Sidekiq::Web.app_url = 'http://www.mysite.com'` [#1875, seuros] `Sidekiq::Web.app_url = 'http://www.mysite.com'` [#1875, seuros]
- Add process tag (`-g tag`) to the Busy page so you can differentiate processes at a glance. [seuros, #1878] - Add process tag (`-g tag`) to the Busy page so you can differentiate processes at a glance. [seuros, #1878]

View file

@ -71,14 +71,10 @@ module Sidekiq
'queues' => @options[:queues].uniq, 'queues' => @options[:queues].uniq,
'labels' => Sidekiq.options[:labels], 'labels' => Sidekiq.options[:labels],
} }
Sidekiq.redis do |conn| # this data doesn't change so dump it to a string
conn.multi do # now so we don't need to dump it every heartbeat.
conn.sadd('processes', key) json = Sidekiq.dump_json(data)
conn.hset(key, 'info', Sidekiq.dump_json(data)) manager.heartbeat(key, data, json)
conn.expire(key, 60)
end
end
manager.heartbeat(key, data)
end end
def stop_heartbeat def stop_heartbeat
@ -89,5 +85,6 @@ module Sidekiq
end end
end end
end end
end end
end end

View file

@ -132,26 +132,27 @@ module Sidekiq
@threads[proxy_id] = thr @threads[proxy_id] = thr
end end
def heartbeat(key, data) def heartbeat(key, data, json)
proctitle = ['sidekiq', Sidekiq::VERSION] proctitle = ['sidekiq', Sidekiq::VERSION]
proctitle << data['tag'] unless data['tag'].empty? proctitle << data['tag'] unless data['tag'].empty?
proctitle << "[#{@busy.size} of #{data['concurrency']} busy]" proctitle << "[#{@busy.size} of #{data['concurrency']} busy]"
proctitle << 'stopping' if stopped? proctitle << 'stopping' if stopped?
$0 = proctitle.join(' ') $0 = proctitle.join(' ')
(key) (key, json)
after(5) do after(5) do
heartbeat(key, data) heartbeat(key, data, json)
end end
end end
private private
def (key) def (key, json)
begin begin
_, _, msg = Sidekiq.redis do |conn| _, _, _, msg = Sidekiq.redis do |conn|
conn.multi do conn.multi do
conn.hmset(key, 'busy', @busy.size, 'beat', Time.now.to_f) conn.sadd('processes', key)
conn.hmset(key, 'info', json, 'busy', @busy.size, 'beat', Time.now.to_f)
conn.expire(key, 60) conn.expire(key, 60)
conn.rpop("#{key}-signals") conn.rpop("#{key}-signals")
end end