diff --git a/lib/bootstrap/bundler.rb b/lib/bootstrap/bundler.rb index bad9aa772..f9b1de00a 100644 --- a/lib/bootstrap/bundler.rb +++ b/lib/bootstrap/bundler.rb @@ -15,10 +15,6 @@ # specific language governing permissions and limitations # under the License. -require "fileutils" -require "stringio" -require 'set' - module LogStash module Bundler extend self @@ -115,6 +111,7 @@ module LogStash require "bundler" require "bundler/cli" + require "fileutils" # create Gemfile from template iff it does not exist unless ::File.exists?(Environment::GEMFILE_PATH) FileUtils.copy( @@ -213,7 +210,7 @@ module LogStash # @param plugin_names [Array] logstash plugin names that are going to update # @return [Array] gem names that plugins depend on, including logstash plugins - def expand_logstash_mixin_dependencies(plugin_names) + def expand_logstash_mixin_dependencies(plugin_names); require 'set' plugin_names = Array(plugin_names) if plugin_names.is_a?(String) # get gem names in Gemfile.lock. If file doesn't exist, it will be generated @@ -299,7 +296,7 @@ module LogStash # capture any $stdout from the passed block. also trap any exception in that block, in which case the trapped exception will be returned # @param [Proc] the code block to execute # @return [String, Exception] the captured $stdout string and any trapped exception or nil if none - def capture_stdout(&block) + def capture_stdout(&block); require 'stringio' old_stdout = $stdout $stdout = StringIO.new("", "w") begin diff --git a/lib/bootstrap/environment.rb b/lib/bootstrap/environment.rb index c0b9972da..61101f52c 100644 --- a/lib/bootstrap/environment.rb +++ b/lib/bootstrap/environment.rb @@ -76,10 +76,7 @@ module LogStash end end -# when launched as a script, not require'd, (currently from bin/logstash and bin/logstash-plugin) the first -# argument is the path of a Ruby file to require and a LogStash::Runner class is expected to be -# defined and exposing the LogStash::Runner#main instance method which will be called with the current ARGV -# currently lib/logstash/runner.rb and lib/pluginmanager/main.rb are called using this. +# when launched as a script, not require'd, (currently from bin/logstash) if $0 == __FILE__ bundler_options = {:without => [:build, :development]} ## Check for dev flags - this needs to be done before the runner is invoked to set bundler options @@ -89,7 +86,7 @@ if $0 == __FILE__ LogStash::Bundler.setup!(bundler_options) require_relative "patches/jar_dependencies" - require ARGV.shift + require 'logstash/runner' exit_status = LogStash::Runner.run("bin/logstash", ARGV) exit(exit_status || 0) end diff --git a/logstash-core/lib/logstash-core/logstash-core.rb b/logstash-core/lib/logstash-core/logstash-core.rb index d58bbb0a5..b3deb9e45 100644 --- a/logstash-core/lib/logstash-core/logstash-core.rb +++ b/logstash-core/lib/logstash-core/logstash-core.rb @@ -23,9 +23,8 @@ require "java" # wrapper. unless $LS_JARS_LOADED jar_path = File.join(File.dirname(File.dirname(__FILE__)), "jars") - $:.unshift jar_path - Dir.glob(jar_path + '/*.jar') do |jar| - require File.basename(jar) + Dir.glob("#{jar_path}/*.jar") do |jar| + load jar end java_import org.logstash.RubyUtil end diff --git a/logstash-core/lib/logstash/runner.rb b/logstash-core/lib/logstash/runner.rb index b2d8b3d22..6c4599b0f 100644 --- a/logstash-core/lib/logstash/runner.rb +++ b/logstash-core/lib/logstash/runner.rb @@ -32,7 +32,6 @@ if !LogStash::OSS end require "clamp" -require "net/http" require "logstash-core/logstash-core" require "logstash/environment" @@ -50,7 +49,6 @@ require 'logstash/plugins' require "logstash/modules/util" require "logstash/bootstrap_check/default_config" require "logstash/bootstrap_check/persisted_queue_config" -require "set" require 'logstash/deprecation_message' java_import 'org.logstash.FileLockFactory' diff --git a/logstash-core/src/main/java/org/logstash/Logstash.java b/logstash-core/src/main/java/org/logstash/Logstash.java index 74ed6423a..eb9c823f3 100644 --- a/logstash-core/src/main/java/org/logstash/Logstash.java +++ b/logstash-core/src/main/java/org/logstash/Logstash.java @@ -241,10 +241,9 @@ public final class Logstash implements Runnable, AutoCloseable { * @return RubyInstanceConfig */ private static RubyInstanceConfig buildConfig(final Path home, final String[] args) { - final String[] arguments = new String[args.length + 2]; - System.arraycopy(args, 0, arguments, 2, args.length); + final String[] arguments = new String[args.length + 1]; + System.arraycopy(args, 0, arguments, 1, args.length); arguments[0] = safePath(home, "lib", "bootstrap", "environment.rb"); - arguments[1] = safePath(home, "logstash-core", "lib", "logstash", "runner.rb"); return initRubyConfig(home, arguments); }