class GovukGuix::Job < Que::Job def run_command(command) logger.debug("#{self.class}: Running command #{command}") Open3.popen2e(*command) do |stdin, stdout_and_stderr, wait_thr| logger.info("#{self.class}: commmand running, pid #{wait_thr.pid}") output = [] stdout_and_stderr.each_line do |line| logger.debug("#{self.class}: #{line}") output << line end exit_status = wait_thr.value unless exit_status == 0 logger.error("#{self.class}: failed, exit status #{exit_status}") raise "#{output.join}\n" end yield(output) end end end