Skip to content
This repository was archived by the owner on Aug 8, 2019. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions code/main.rb
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,19 @@ def flash_now(type, msg)
erb :proc_list, :layout => false, :locals => {:queues => RQ::QueueMgrClient.queues, :procs => procs}
end

post '/q/:name' do
begin
qc = RQ::QueueClient.new(params[:name])
rescue RQ::RqQueueNotFound
throw :halt, [404, "404 - Queue not found"]
end

ok, num_msgs = qc.delete_message({:all => params[:state]})

flash :notice, "Deleted #{num_msgs} messages in #{params[:state]} state"
redirect request.path_info
end

get '/q/:name' do
if params[:name].index(".txt")
content_type 'text/plain', :charset => 'utf-8'
Expand Down
6 changes: 6 additions & 0 deletions code/public/css/rq.css
Original file line number Diff line number Diff line change
Expand Up @@ -206,3 +206,9 @@ th.err {background: #f99}
}
.hidden {display: none}
p {margin-bottom: 5px}

.float-right {
float: right;
padding: 0px;
margin: 0px;
}
21 changes: 19 additions & 2 deletions code/queue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1928,13 +1928,30 @@ def handle_request(sock)
json = packet.split(' ', 2)[1]
options = JSON.parse(json)

if options.has_key?('all')
state = options['all']
unless %w{prep que done err relay}.include? state
resp = [ "fail", "invalid state to delete all messages" ].to_json
send_packet(sock, resp)
return
end

all_msgs = Dir.glob("#{@queue_path}/#{state}/*")
all_msgs.each do |dir|
FileUtils.rm_rf(dir)
end
resp = [ "ok", all_msgs.length ].to_json
send_packet(sock, resp)
return
end

if not options.has_key?('msg_id')
resp = [ "fail", "lacking 'msg_id' field"].to_json
resp = [ "fail", "lacking 'msg_id' field" ].to_json
send_packet(sock, resp)
return
end

resp = [ "fail", "unknown reason"].to_json
resp = [ "fail", "unknown reason" ].to_json

if lookup_msg(options, '*')
delete_msg!(options)
Expand Down
9 changes: 8 additions & 1 deletion code/views/queue.erb
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,14 @@
<% if qc.name != 'relay' %>
<th class="done"><h4>DONE</h4><%= num_msgs['done'] %></th>
<% end %>
<th class="err"><h4>ERR</h4><%= num_msgs['err'] %></th>
<th class="err">
<h4>ERR</h4><%= num_msgs['err'] %>
<form action="<%= request.path_info %>" method="post" class="float-right">
<input type="hidden" value="<%= qc.name %>" name="name" />
<input type="hidden" value="err" name="state" />
<input type="submit" value="Delete All" />
</form>
</th>
</tr>
</thead>
<tbody>
Expand Down