Sha256: 88b1993456346f94c948699d7b4357c107ed8e29933fd953b2d21c8af2c5ee37

Contents?: true

Size: 932 Bytes

Versions: 25

Compression:

Stored size: 932 Bytes

Contents

require 'open3'

module ForemanInventoryUpload
  module Async
    class ShellProcess < ::ApplicationJob
      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

      def command
      end

      def env
        {}
      end

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

Version data entries

25 entries across 25 versions & 2 rubygems

Version Path
foreman_rh_cloud-0.9.5 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-1.0.5 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-2.0.5 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-0.9.4.1 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-1.0.4.1 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-1.0.4 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-2.0.4 lib/foreman_inventory_upload/async/shell_process.rb
foreman_rh_cloud-0.9.4 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-2.0.4.pre.2 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-2.0.4.pre.1 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-2.0.3 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-1.0.3 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-0.9.2 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-1.0.2 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-0.9.1 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-1.0.1 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-0.9.0 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-1.0.0 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-1.0.0.beta7 lib/foreman_inventory_upload/async/shell_process.rb
foreman_inventory_upload-1.0.0.beta6 lib/foreman_inventory_upload/async/shell_process.rb