10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/bunnish/command/delete.rb', line 10
def self.run(argv, input_stream=$stdin, output_stream=$stdout, error_stream=$stderr)
params = Bunnish.parse_opts(argv)
host = params[:host]
port = params[:port]
user = params[:user]
password = params[:password]
durable = params[:durable]
log_label = params[:log_label]
queue_name_list = argv.shift
if queue_name_list.nil?
Bunnish.logger.info("queue-name is not set")
return 0
end
queue_name_list = queue_name_list.split(/[, \r\n]/)
queue_name_list.delete('')
bunny = Bunny.new(:logging => false, :spec => '09', :host=>host, :port=>port, :user=>user, :pass=>password)
bunny.start
exit_code = 0
while queue_name = self.fetch_queue_name(queue_name_list, input_stream)
queue = bunny.queue(queue_name, :durable=>durable)
if queue.nil? then
Bunnish.logger.info "#{log_label} #{queue_name} does not exist"
next
end
result = queue.delete
if result == :delete_ok then
Bunnish.logger.info "#{log_label} deleted #{queue_name}"
else
Bunnish.logger.warn "#{log_label} failed to delete #{queue_name}"
exit_code = 1
end
end
bunny.stop
return exit_code
end
|