Module: Carnivore::Utils::Failure
Overview
Failure utilities
Instance Method Summary collapse
-
#execute_and_retry_forever(action) ⇒ Object
Attempt to execute provided block.
Instance Method Details
#execute_and_retry_forever(action) ⇒ Object
Attempt to execute provided block. If exception is raised, log and pause before retry. Do this until success.
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/carnivore/utils/failure.rb', line 14 def execute_and_retry_forever(action) begin debug "Starting #{action} process" result = yield debug "Completed #{action} process" result rescue Zoidberg::DeadException raise rescue => e error "#{action.to_s.capitalize} process encountered an error: #{e.class} - #{e}" debug "#{e.class}: #{e}\n#{e.backtrace.join("\n")}" warn "Pausing for 5 seconds then retrying #{action}" sleep(5) retry end end |