Skip to content
This repository has been archived by the owner on Aug 8, 2019. It is now read-only.

Commit

Permalink
Include more queue overview information in /q.json
Browse files Browse the repository at this point in the history
  • Loading branch information
sodabrew committed Sep 24, 2015
1 parent 26d8da9 commit 87ed7e7
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 10 deletions.
32 changes: 31 additions & 1 deletion code/main.rb
Expand Up @@ -119,6 +119,10 @@ def msgs_labels
%w[prep que run err done relayed]
end

def builtin_queue? q
%w[relay cleaner webhook rq_router].include? q
end

def flash(type, msg)
h = session[:flash] || {}
h[type] = msg
Expand Down Expand Up @@ -192,7 +196,32 @@ def flash(type, msg)

get '/q.json' do
content_type 'application/json'
queuemgr.queues.to_json
builtin_queues, custom_queues = queuemgr.queues.sort.partition { |q| builtin_queue? q }

(custom_queues.map do |name|
qc = get_queueclient(name)
{
'name' => name,
'status' => qc.status,
'ping' => qc.ping,
'pid' => qc.read_pid,
'uptime' => qc.uptime,
'counts' => Hash[ msgs_labels.zip(qc.num_messages.values_at(*msgs_labels)) ],
# 'schedule' => qc.config[1]['schedule']...
}
end +
builtin_queues.map do |name|
qc = get_queueclient(name)
{
'name' => name,
'status' => qc.status,
'ping' => qc.ping,
'pid' => qc.read_pid,
'uptime' => qc.uptime,
'counts' => Hash[ msgs_labels.zip(qc.num_messages.values_at(*msgs_labels)) ],
# 'schedule' => qc.config[1]['schedule']...
}
end).to_json
end

get '/search' do
Expand Down Expand Up @@ -232,6 +261,7 @@ def flash(type, msg)
}
end
end
content_type 'application/json'
data.to_json
end

Expand Down
10 changes: 1 addition & 9 deletions code/views/main.erb
Expand Up @@ -8,15 +8,7 @@
<h2>Queue List</h2>
<%
if queuemgr.running?
queues = queuemgr.queues.sort
builtin_queues, custom_queues = [], []
queues.each do |q|
if %w{relay cleaner webhook rq_router}.include? q
builtin_queues << q
else
custom_queues << q
end
end
builtin_queues, custom_queues = queuemgr.queues.sort.partition { |q| builtin_queue? q }
-%>
<table id="queue-list" cellspacing="0" cellpadding="5">
<thead>
Expand Down

0 comments on commit 87ed7e7

Please sign in to comment.