From bc1ffc5214ab3f563b60523d9c349fab7974e634 Mon Sep 17 00:00:00 2001 From: Christopher Baines Date: Sun, 18 Feb 2018 11:23:41 +0000 Subject: Add some govuk-guix related jobs And various other views and routes. --- app/jobs/govuk_guix/job.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 app/jobs/govuk_guix/job.rb (limited to 'app/jobs/govuk_guix/job.rb') diff --git a/app/jobs/govuk_guix/job.rb b/app/jobs/govuk_guix/job.rb new file mode 100644 index 0000000..0161cb1 --- /dev/null +++ b/app/jobs/govuk_guix/job.rb @@ -0,0 +1,24 @@ +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 -- cgit v1.2.3