Sha256: 4f045b2c8c3e428befc793087533ff98969a7847046180b34577dd1e91cdc86a

Contents?: true

Size: 740 Bytes

Versions: 1

Compression:

Stored size: 740 Bytes

Contents

require 'open3'
require 'webhookd/logging'

module Webhookd
  class Commandrunner

    include Logging

    def initialize(command)
      @command = command
    end

    def run
      begin
        logger.info "Running command: #{@command}"
        Open3::popen2e(@command) { |stdin, stdout_err, wait_thr|
          while line = stdout_err.gets
            logger.debug("Command output: #{line.strip}")
          end
          if wait_thr.value.success?
            logger.info "command successful"
            return true
          else
            logger.error "command failed"
            return false
          end
        }
      rescue Exception => e
        logger.fatal "Completely failed: #{e.message}"
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
webhookd-0.0.7 lib/webhookd/command_runner.rb