Enable DEBUG=1 when using bundler related task

When running any logstash's command you can use DEBUG=1 which should
give the user a bit more information about what LS is doing.

This PR changes the behavior of bundler to make sure its run with the
`--verbose` flag.

Fixes #5199
This commit is contained in:
Pier-Hugues Pellerin 2016-04-26 12:28:36 -04:00
parent 99daeffac5
commit 493c50c427

View file

@ -104,13 +104,22 @@ module LogStash
::Bundler.settings[:gemfile] = LogStash::Environment::GEMFILE_PATH ::Bundler.settings[:gemfile] = LogStash::Environment::GEMFILE_PATH
::Bundler.settings[:without] = options[:without].join(":") ::Bundler.settings[:without] = options[:without].join(":")
if !debug?
# Will deal with transient network errors
execute_bundler_with_retry(options)
else
options[:verbose] = true
execute_bundler(options)
end
end
def execute_bundler_with_retry(options)
try = 0 try = 0
# capture_stdout also traps any raised exception and pass them back as the function return [output, exception] # capture_stdout also traps any raised exception and pass them back as the function return [output, exception]
output, exception = capture_stdout do output, exception = capture_stdout do
loop do loop do
begin begin
::Bundler.reset! execute_bundler(options)
::Bundler::CLI.start(bundler_arguments(options))
break break
rescue ::Bundler::VersionConflict => e rescue ::Bundler::VersionConflict => e
$stderr.puts("Plugin version conflict, aborting") $stderr.puts("Plugin version conflict, aborting")
@ -132,12 +141,20 @@ module LogStash
end end
end end
end end
raise exception if exception raise exception if exception
return output return output
end end
def execute_bundler(options)
::Bundler.reset!
::Bundler::CLI.start(bundler_arguments(options))
end
def debug?
ENV["DEBUG"]
end
# build Bundler::CLI.start arguments array from the given options hash # build Bundler::CLI.start arguments array from the given options hash
# @param option [Hash] the invoke! options hash # @param option [Hash] the invoke! options hash
# @return [Array<String>] Bundler::CLI.start string arguments array # @return [Array<String>] Bundler::CLI.start string arguments array
@ -162,6 +179,8 @@ module LogStash
arguments << "--all" if options[:all] arguments << "--all" if options[:all]
end end
arguments << "--verbose" if options[:verbose]
arguments.flatten arguments.flatten
end end