Sha256: c082457dd99fe6fe3316d58cb6d5886010c5f5540e4e87c89b3c6eac06ac428d
Contents?: true
Size: 1.09 KB
Versions: 2
Compression:
Stored size: 1.09 KB
Contents
require 'celluloid' module Buildbox class Agent include Celluloid include Celluloid::Logger def initialize(access_token, api = Buildbox::API.new) @api = api @access_token = access_token @queue = [] end def process unless @processing @processing = true scheduled_builds.each { |build| @queue << build } while build = @queue.pop do # Let the agent know that we're about to start running this build @api.update_build(@access_token, build, :agent_accepted => @access_token) Monitor.new(build, @access_token, @api).async.monitor Runner.new(build).start end @processing = false end end private def scheduled_builds @api.agent(@access_token, :hostname => hostname, :version => Buildbox::VERSION) @api.scheduled_builds(@access_token) rescue Buildbox::API::AgentNotFoundError warn "Agent `#{@access_token}` does not exist" [] # return empty array to avoid breakage end def hostname `hostname`.chomp end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
buildbox-0.4.1 | lib/buildbox/agent.rb |
buildbox-0.4 | lib/buildbox/agent.rb |