Skip to content

Commit

Permalink
Update stopping value every heartbeat
Browse files Browse the repository at this point in the history
  • Loading branch information
Jarrod Carlson committed Jan 7, 2016
1 parent c2b260d commit 097eef9
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
10 changes: 5 additions & 5 deletions lib/sidekiq/api.rb
Expand Up @@ -674,13 +674,13 @@ def each
# you'll be happier this way
result = conn.pipelined do
procs.each do |key|
conn.hmget(key, 'info', 'busy', 'beat')
conn.hmget(key, 'info', 'busy', 'beat', 'quiet')
end
end

result.each do |info, busy, at_s|
result.each do |info, busy, at_s, quiet|
hash = Sidekiq.load_json(info)
yield Process.new(hash.merge('busy' => busy.to_i, 'beat' => at_s.to_f))
yield Process.new(hash.merge('busy' => busy.to_i, 'beat' => at_s.to_f, 'quiet' => quiet))
end
end

Expand Down Expand Up @@ -738,9 +738,9 @@ def stop!
def dump_threads
signal('TTIN')
end

def stopping?
self['stopping']
self['quiet'] == 'true'
end

private
Expand Down
5 changes: 2 additions & 3 deletions lib/sidekiq/launcher.rb
Expand Up @@ -95,7 +95,7 @@ def ❤(key, json)
_, _, _, msg = Sidekiq.redis do |conn|
conn.pipelined do
conn.sadd('processes', key)
conn.hmset(key, 'info', json, 'busy', Processor::WORKER_STATE.size, 'beat', Time.now.to_f)
conn.hmset(key, 'info', json, 'busy', Processor::WORKER_STATE.size, 'beat', Time.now.to_f, 'quiet', @done)
conn.expire(key, 60)
conn.rpop("#{key}-signals")
end
Expand Down Expand Up @@ -127,8 +127,7 @@ def start_heartbeat
'concurrency' => @options[:concurrency],
'queues' => @options[:queues].uniq,
'labels' => @options[:labels],
'identity' => k,
'stopping' => @done
'identity' => k
}
# this data doesn't change so dump it to a string
# now so we don't need to dump it every heartbeat.
Expand Down

0 comments on commit 097eef9

Please sign in to comment.