Class: Drunker::Executor
- Inherits:
-
Object
- Object
- Drunker::Executor
- Defined in:
- lib/drunker/executor.rb,
lib/drunker/executor/iam.rb,
lib/drunker/executor/builder.rb
Defined Under Namespace
Constant Summary collapse
- RETRY_LIMIT =
10
Instance Method Summary collapse
-
#initialize(source:, config:, logger:) ⇒ Executor
constructor
A new instance of Executor.
- #run ⇒ Object
Constructor Details
#initialize(source:, config:, logger:) ⇒ Executor
Returns a new instance of Executor.
5 6 7 8 9 10 11 12 13 |
# File 'lib/drunker/executor.rb', line 5 def initialize(source:, config:, logger:) @project_name = "drunker-executor-#{Time.now.to_i}" @source = source logger.info("Creating artifact...") @artifact = Drunker::Artifact.new(config: config, logger: logger) @config = config @client = Aws::CodeBuild::Client.new(config.) @logger = logger end |
Instance Method Details
#run ⇒ Object
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/drunker/executor.rb', line 15 def run setup_project do builders = create_builders loop do start_builders builders restart_failed_builders builders ran, waiting = builders.partition(&:ran?) running, finished = ran.partition(&:running?) finished.select(&:failed?).each do |builder| builder.errors.each do |error| logger.warn("Build failed: #{failed.build_id}") logger.warn("\tphase_type: #{error[:phase_type]}") logger.warn("\tphase_status: #{error[:phase_status]}") logger.warn("\tstatus: #{error[:status]}") logger.warn("\tmessage: #{error[:message]}") end end if waiting.count.zero? && running.count.zero? logger.info("Build is completed!") break end logger.info("Waiting builders: #{finished.count}/#{builders.count}, queues: #{waiting.count}") sleep 5 builders.each(&:refresh) end artifact.layers # load artifact layers from S3 end artifact end |