Class: Buildbox::Agent

Inherits:
Object
  • Object
show all
Includes:
Celluloid, Celluloid::Logger
Defined in:
lib/buildbox/agent.rb

Instance Method Summary collapse

Constructor Details

#initialize(access_token, api = Buildbox::API.new) ⇒ Agent

Returns a new instance of Agent.



8
9
10
11
# File 'lib/buildbox/agent.rb', line 8

def initialize(access_token, api = Buildbox::API.new)
  @api          = api
  @access_token = access_token
end

Instance Method Details

#workObject



13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/buildbox/agent.rb', line 13

def work
  builds = scheduled_builds

  # Run the builds one at a time
  builds.each do |build|
    # Let the agent know that we're about to start working on this build
    @api.update_build(build, :agent_accepted => @access_token)

    Monitor.new(build, @api).async.monitor
    Runner.new(build).start
  end
end