class ForemanInventoryUpload::Async::ShellProcess

Public Instance Methods

command() click to toggle source
# File lib/foreman_inventory_upload/async/shell_process.rb, line 24
def command
end
env() click to toggle source
# File lib/foreman_inventory_upload/async/shell_process.rb, line 27
def env
  {}
end
logger() click to toggle source
# File lib/foreman_inventory_upload/async/shell_process.rb, line 31
def logger
  Foreman::Logging.logger('background')
end
perform(instance_label) click to toggle source
# File lib/foreman_inventory_upload/async/shell_process.rb, line 6
def perform(instance_label)
  klass_name = self.class.name
  logger.debug("Starting #{klass_name} with label #{instance_label}")
  progress_output = ProgressOutput.register(instance_label)
  Open3.popen2e(env, command) do |_stdin, stdout_stderr, wait_thread|
    progress_output.status = "Running in pid #{wait_thread.pid}"

    stdout_stderr.each do |out_line|
      progress_output.write_line(out_line)
    end

    progress_output.status = wait_thread.value.to_s
  end
  logger.debug("Finished job #{klass_name} with label #{instance_label}")
ensure
  progress_output.close
end