Sha256: a622b0f0e18bf422d38ae339fb9ac5981c43c73fb8f977ed8a9113f45aaef39c

Contents?: true

Size: 971 Bytes

Versions: 13

Compression:

Stored size: 971 Bytes

Contents

require 'open3'

module ForemanInventoryUpload
  module Async
    class ShellProcess < ::ApplicationJob
      include AsyncHelpers

      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(hash_to_s(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

      def command
      end

      def env
        {}
      end

      def logger
        Foreman::Logging.logger('background')
      end
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
foreman_rh_cloud-0.9.10 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-1.0.10 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-1.0.9 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-0.9.9 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-0.9.8 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-1.0.8 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-2.0.8 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-0.9.7 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-1.0.7 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-2.0.7 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-0.9.6 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-1.0.6 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-2.0.6 lib/foreman_inventory_upload/async/shell_process.rb