Skip to content

Commit

Permalink
Capture ctrl-c properly
Browse files Browse the repository at this point in the history
  • Loading branch information
John A. Barbuto committed Aug 19, 2012
1 parent 252d28b commit 9135962
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lib/logstash-cli/command/tail.rb
Expand Up @@ -32,6 +32,8 @@ def _tail(options)
end

AMQP.start(settings) do |connection, open_ok|
trap("INT") { puts "Shutting down..."; connection.close { EM.stop }; exit }

channel = AMQP::Channel.new(connection, :auto_recovery => true)

channel.queue("", :auto_delete => auto_delete, :peristent => persistent , :durable => durable) do |queue, declare_ok|
Expand All @@ -52,10 +54,9 @@ def _tail(options)
rescue AMQP::PossibleAuthenticationFailureError => ex
puts "Possible Authentication error:\nthe AMQP connection URL used is #{amqp_url}\n\nDetail Info:\n#{ex}"
exit -1
rescue Exception => ex
puts "Error occured: #{ex}"
rescue StandardError => ex
puts "Error occurred: #{ex}"
exit -1
end
trap("INT") { puts "Shutting down..."; connection.close { EM.stop };exit }
end
end

0 comments on commit 9135962

Please sign in to comment.