mirror of
https://github.com/mperham/sidekiq.git
synced 2022-11-09 13:52:34 -05:00
Add support for showing the Sidekiq Enterprise cluster leader process in Web UI, fixes mperham/sidekiq#2867
This commit is contained in:
parent
ce5925aaf3
commit
79f452c68d
3 changed files with 23 additions and 6 deletions
|
@ -7,6 +7,7 @@ Please see [http://sidekiq.org/](http://sidekiq.org/) for more details and how t
|
|||
HEAD
|
||||
-------------
|
||||
|
||||
- Show process "leader" tag on Busy page, requires Sidekiq 5.0.1 [#2867]
|
||||
- Capture custom metrics with the `save_history` API. [#2815]
|
||||
- Implement new `unique_util: 'start'` policy option. [#3471]
|
||||
|
||||
|
|
|
@ -731,7 +731,7 @@ module Sidekiq
|
|||
next if info.nil?
|
||||
|
||||
hash = Sidekiq.load_json(info)
|
||||
yield Process.new(hash.merge('busy' => busy.to_i, 'beat' => at_s.to_f, 'quiet' => quiet))
|
||||
yield Process.new(hash.merge('busy' => busy.to_i, 'beat' => at_s.to_f, 'quiet' => quiet)), leader
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -745,6 +745,18 @@ module Sidekiq
|
|||
def size
|
||||
Sidekiq.redis { |conn| conn.scard('processes') }
|
||||
end
|
||||
|
||||
# Returns the identity of the current cluster leader or "" if no leader.
|
||||
# This is a Sidekiq Enterprise feature, will always return "" in Sidekiq
|
||||
# or Sidekiq Pro.
|
||||
def leader
|
||||
@leader ||= begin
|
||||
x = Sidekiq.redis {|c| c.get("dear-leader") }
|
||||
# need a non-falsy value so we can memoize
|
||||
x = "" unless x
|
||||
x
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
#
|
||||
|
@ -779,6 +791,10 @@ module Sidekiq
|
|||
@attribs[key]
|
||||
end
|
||||
|
||||
def identity
|
||||
self['identity']
|
||||
end
|
||||
|
||||
def quiet!
|
||||
signal('TSTP')
|
||||
end
|
||||
|
@ -807,9 +823,6 @@ module Sidekiq
|
|||
end
|
||||
end
|
||||
|
||||
def identity
|
||||
self['identity']
|
||||
end
|
||||
end
|
||||
|
||||
##
|
||||
|
|
|
@ -22,7 +22,7 @@
|
|||
<th><%= t('Busy') %></th>
|
||||
<th> </th>
|
||||
</thead>
|
||||
<% processes.each do |process| %>
|
||||
<% processes.each do |process,leader| %>
|
||||
<tr>
|
||||
<td class="box">
|
||||
<%= "#{process['hostname']}:#{process['pid']}" %>
|
||||
|
@ -31,7 +31,10 @@
|
|||
<span class="label label-info"><%= label %></span>
|
||||
<% end %>
|
||||
<% if process.stopping? %>
|
||||
<span class="label label-danger">Quiet</span>
|
||||
<span class="label label-danger">quiet</span>
|
||||
<% end %>
|
||||
<% if process.identity == leader %>
|
||||
<span class="label label-warning">leader</span>
|
||||
<% end %>
|
||||
<br>
|
||||
<b><%= "#{t('Queues')}: " %></b>
|
||||
|
|
Loading…
Reference in a new issue