lib/buildbox/runner.rb in buildbox-0.3.3 vs lib/buildbox/runner.rb in buildbox-0.3.4
- old
+ new
@@ -1,16 +1,13 @@
-require 'rubygems'
require 'celluloid'
require 'fileutils'
module Buildbox
class Runner
include Celluloid
include Celluloid::Logger
- attr_reader :build
-
def initialize(build)
@build = build
end
def start
@@ -18,27 +15,25 @@
FileUtils.mkdir_p(directory_path)
File.open(script_path, 'w+') { |file| file.write(@build.script) }
File.chmod(0777, script_path)
- info "Running script: #{script_path}"
+ command = Command.new(script_path, :environment => @build.env, :directory => directory_path)
+ @build.output = ""
+ @build.process = command.process
@build.started_at = Time.now.utc
- build.output = ""
- result = Command.run(script_path, :environment => @build.env, :directory => directory_path) do |command, chunk|
- build.pid = command.pid
- build.output << chunk
- end
+ command.start { |chunk| @build.output << chunk }
- build.output = result.output
- build.exit_status = result.exit_status
+ @build.output = command.output
+ @build.exit_status = command.exit_status
File.delete(script_path)
@build.finished_at = Time.now.utc
- info "#{@build.namespace} ##{@build.id} finished with exit status #{result.exit_status}"
+ info "#{@build.namespace} ##{@build.id} finished with exit status #{command.exit_status}"
end
private
def directory_path