class SolrWrapper::Popen4Runner

Runs a command using popen4 (typically for JRuby)

Public Instance Methods

run(stringio) click to toggle source
# File lib/solr_wrapper/popen4_runner.rb, line 4
def run(stringio)
  pid, input, output, error = IO.popen4(command)
  if config.verbose? && !silence_output?
    IO.copy_stream(output, $stderr)
    IO.copy_stream(error, $stderr)
  else
    IO.copy_stream(output, stringio)
    IO.copy_stream(error, stringio)
  end

  input.close
  output.close
  error.close
  exit_status = Process.waitpid2(pid).last
  stringio.rewind
  exit_status
end

Private Instance Methods

command() click to toggle source
# File lib/solr_wrapper/popen4_runner.rb, line 24
def command
  env_str + ' ' + argument_list.join(' ')
end
env_str() click to toggle source
# File lib/solr_wrapper/popen4_runner.rb, line 28
def env_str
  config.env.map { |k, v| "#{Shellwords.escape(k)}=#{Shellwords.escape(v)}" }.join(' ')
end