Class: Elevage::ProvisionerRunQueue
- Inherits:
-
Object
- Object
- Elevage::ProvisionerRunQueue
- Defined in:
- lib/elevage/provisionerrunqueue.rb
Overview
ProvisionerRunQueue class
Instance Attribute Summary collapse
-
#build_status_interval ⇒ Object
Returns the value of attribute build_status_interval.
-
#busy_wait_timeout ⇒ Object
Returns the value of attribute busy_wait_timeout.
-
#max_concurrent ⇒ Object
Returns the value of attribute max_concurrent.
-
#provisioners ⇒ Object
Returns the value of attribute provisioners.
-
#running_tasks ⇒ Object
readonly
Returns the value of attribute running_tasks.
Instance Method Summary collapse
-
#initialize ⇒ ProvisionerRunQueue
constructor
Public: Initialize the object.
-
#run ⇒ Object
Public: run() - Process the queue rubocop:disable MethodLength.
-
#to_s ⇒ Object
Public: Display a string representation rubocop:disable MethodLength.
Constructor Details
#initialize ⇒ ProvisionerRunQueue
Public: Initialize the object
13 14 15 16 17 18 19 20 |
# File 'lib/elevage/provisionerrunqueue.rb', line 13 def initialize @running_tasks = 0 # We start out with nothing running @max_concurrent = BUILD_CONCURRENT_DEFAULT @busy_wait_timeout = BUILD_CHILD_WAIT_TIMEOUT @build_status_interval = BUILD_STATUS_INTERVAL @provisioners = [] @children = {} end |
Instance Attribute Details
#build_status_interval ⇒ Object
Returns the value of attribute build_status_interval.
10 11 12 |
# File 'lib/elevage/provisionerrunqueue.rb', line 10 def build_status_interval @build_status_interval end |
#busy_wait_timeout ⇒ Object
Returns the value of attribute busy_wait_timeout.
9 10 11 |
# File 'lib/elevage/provisionerrunqueue.rb', line 9 def busy_wait_timeout @busy_wait_timeout end |
#max_concurrent ⇒ Object
Returns the value of attribute max_concurrent.
8 9 10 |
# File 'lib/elevage/provisionerrunqueue.rb', line 8 def max_concurrent @max_concurrent end |
#provisioners ⇒ Object
Returns the value of attribute provisioners.
7 8 9 |
# File 'lib/elevage/provisionerrunqueue.rb', line 7 def provisioners @provisioners end |
#running_tasks ⇒ Object (readonly)
Returns the value of attribute running_tasks.
6 7 8 |
# File 'lib/elevage/provisionerrunqueue.rb', line 6 def running_tasks @running_tasks end |
Instance Method Details
#run ⇒ Object
Public: run() - Process the queue rubocop:disable MethodLength
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/elevage/provisionerrunqueue.rb', line 24 def run puts "#{Time.now} [#{$$}]: Provisioning started." @provisioners.each do |provisioner| # Make sure we're not running more jobs than we're allowed wait_for_tasks child_pid = fork do provision_task task: provisioner end @children[child_pid] = provisioner.name @running_tasks += 1 end # Hang around until we collect all the rest of the children wait_for_tasks state: :collect puts "#{Time.now} [#{$$}]: Provisioning completed." end |
#to_s ⇒ Object
Public: Display a string representation rubocop:disable MethodLength
43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/elevage/provisionerrunqueue.rb', line 43 def to_s puts "Running Tasks: #{@running_tasks}" puts "Max Concurrency: #{@max_concurrent}" puts "Wait status interval: #{@build_status_interval}" puts 'Current Child processes:' @children.each do |pid, name| puts " - [#{pid}]: #{name}" end puts 'Queued Provisioners:' @provisioners.each do |provisioner| puts " - #{provisioner.name}" end end |