Module: EC2Launcher::BackoffRunner
- Included in:
- Launcher
- Defined in:
- lib/ec2launcher/backoff_runner.rb
Overview
Helper module to run AWS requests.
Instance Method Summary collapse
-
#run_with_backoff(max_time, sleep_time, message, &block) ⇒ Object
we exceed the allowed AWS RequestLimit.
Instance Method Details
#run_with_backoff(max_time, sleep_time, message, &block) ⇒ Object
we exceed the allowed AWS RequestLimit.
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/ec2launcher/backoff_runner.rb', line 16 def run_with_backoff(max_time, sleep_time, , &block) if sleep_time > max_time puts "AWS::EC2::Errors::RequestLimitExceeded ... failed #{}" return false end begin yield rescue AWS::EC2::Errors::RequestLimitExceeded puts "AWS::EC2::Errors::RequestLimitExceeded ... retrying #{} in #{sleep_time} seconds" sleep sleep_time run_with_backoff(max_time, sleep_time * 2, , &block) rescue AWS::EC2::Errors::InstanceLimitExceeded puts "AWS::EC2::Errors::InstanceLimitExceeded ... aborting launch." return false rescue StdError => bang print "Error for #{}: #{bang}" return false end true end |