Sha256: 10472c2b7eb087e6e946f200d2f72848d34177d3cfbcb83e1f5ecd4198de4999

Contents?: true

Size: 709 Bytes

Versions: 1

Compression:

Stored size: 709 Bytes

Contents

require 'rubygems'
require 'celluloid'

module Buildbox
  class Monitor
    include Celluloid

    def initialize(build, api)
      @build = build
      @api   = api
    end

    def monitor
      loop do
        # There is an edge case where the build finishes between making the
        # update_build http call, and breaking. So to make sure we're using the
        # same build object throughout this call, we can just deep dup it.
        build = Marshal.load(Marshal.dump(@build))
        @api.update_build(build) if build.started? || build.finished?

        if build.finished?
          break
        else
          sleep 3 # 3 seconds seems reasonable for now
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
buildbox-0.3.2 lib/buildbox/monitor.rb