Class: Buildbox::Server

Inherits:
Object
  • Object
show all
Defined in:
lib/buildbox/server.rb

Constant Summary collapse

INTERVAL =
5

Instance Method Summary collapse

Constructor Details

#initialize(config = Buildbox.config, logger = Buildbox.logger) ⇒ Server

Returns a new instance of Server.



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

def initialize(config = Buildbox.config, logger = Buildbox.logger)
  @config      = config
  @logger      = logger
  @supervisors = []
end

Instance Method Details

#startObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'lib/buildbox/server.rb', line 13

def start
  Celluloid.logger = @logger
  Celluloid::Actor[:artifact_poster_pool] = Artifact::Poster.pool

  agent_access_tokens.each do |access_token|
    @supervisors << Buildbox::Agent.supervise(access_token)

    @logger.info "Agent with access token `#{access_token}` has started."
  end

  loop do
    @supervisors.each do |supervisor|
      supervisor.actors.first.async.process
    end

    wait INTERVAL
  end
end