Sha256: 1f93229da461354215404d5263ee9b6a3ff7d5c7320921657c419adab4b1ca03

Contents?: true

Size: 1.03 KB

Versions: 7

Compression:

Stored size: 1.03 KB

Contents

require 'celluloid'

module Buildbox
  class Monitor
    include Celluloid

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

    def monitor
      loop do
        if @build.started?
          # As the build can finish in between doing the update_build api_call
          # and checking to see if the build has finished, we make sure we use the
          # same finished_at timestamp throughout the entire method.
          finished_at = @build.finished_at

          updated_build = @api.update_build(@build, :started_at  => @build.started_at,
                                                    :finished_at => finished_at,
                                                    :output      => @build.output,
                                                    :exit_status => @build.exit_status)

          if updated_build.state == 'canceled' && !@build.cancelling?
            Buildbox::Canceler.new(@build).async.cancel
          end

          break if finished_at
        end

        sleep 1
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
buildbox-0.3.9.1 lib/buildbox/monitor.rb
buildbox-0.3.9 lib/buildbox/monitor.rb
buildbox-0.3.8 lib/buildbox/monitor.rb
buildbox-0.3.7 lib/buildbox/monitor.rb
buildbox-0.3.6 lib/buildbox/monitor.rb
buildbox-0.3.5 lib/buildbox/monitor.rb
buildbox-0.3.4 lib/buildbox/monitor.rb