Sha256: ead91d5a6880c6c8e62c7e0407fd1196cf588d247578529df86f94dc7dd91f5d

Contents?: true

Size: 604 Bytes

Versions: 10

Compression:

Stored size: 604 Bytes

Contents

# encoding: utf-8
# This file is distributed under New Relic's license terms.
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.

module Multiverse
  module ShellUtils
    module_function

    def try_command_n_times(cmd, n, wait_time=1)
      count = 0
      loop do
        count += 1
        result = `#{cmd}`
        if $?.success?
          return result
        elsif count < n
          sleep wait_time
          redo
        else
          puts "System command: #{cmd} failed #{n} times. Giving up..."
          return result
        end
      end
    end

  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
newrelic_rpm-4.1.0.333 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-4.0.0.332 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-3.18.1.330 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-3.18.0.329 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-3.17.2.327 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-3.17.1.326 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-3.17.0.325 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-3.16.3.323 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-3.16.2.321 test/multiverse/lib/multiverse/shell_utils.rb
newrelic_rpm-3.16.1.320 test/multiverse/lib/multiverse/shell_utils.rb