lib/request_log_analyzer/controller.rb in request-log-analyzer-1.2.1 vs lib/request_log_analyzer/controller.rb in request-log-analyzer-1.2.3

- old
+ new

@@ -189,18 +189,15 @@ # 5. Call report on every aggregator # 6. Finalize Source def run! @aggregators.each { |agg| agg.prepare } + install_signal_handlers - begin - @source.each_request do |request| - aggregate_request(filter_request(request)) - end - rescue Interrupt => e - handle_progress(:interrupted) - puts "Caught interrupt! Stopped parsing." + @source.each_request do |request| + aggregate_request(filter_request(request)) + break if @interrupted end @aggregators.each { |agg| agg.finalize } @output.header @@ -214,9 +211,17 @@ puts "Report written to: " + File.expand_path(@output.io.path) puts "Need an expert to analyze your application?" puts "Mail to contact@railsdoctors.com or visit us at http://railsdoctors.com" puts "Thanks for using request-log-analyzer!" @output.io.close + end + end + + def install_signal_handlers + Signal.trap("INT") do + handle_progress(:interrupted) + puts "Caught interrupt! Stopping parsing..." + @interrupted = true end end end end