Class: Webhookd::Commandrunner
- Inherits:
-
Object
- Object
- Webhookd::Commandrunner
- Includes:
- Logging
- Defined in:
- lib/webhookd/command_runner.rb
Instance Method Summary collapse
-
#initialize(command) ⇒ Commandrunner
constructor
A new instance of Commandrunner.
- #run ⇒ Object
Methods included from Logging
configure_logger_for, #logger, logger_for
Constructor Details
#initialize(command) ⇒ Commandrunner
Returns a new instance of Commandrunner.
9 10 11 |
# File 'lib/webhookd/command_runner.rb', line 9 def initialize(command) @command = command end |
Instance Method Details
#run ⇒ Object
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
# File 'lib/webhookd/command_runner.rb', line 13 def run begin logger.info "Running command: #{@command}" Open3::popen2e(@command) { |stdin, stdout_err, wait_thr| while line = stdout_err.gets logger.info("STDOUTERR: #{line.strip}") end if wait_thr.value.success? logger.info "command successfully finished" return true else logger.error "command failed" return false end } rescue Exception => e logger.fatal "command running completely failed: #{e.}" end end |