diff options
author | Tim Smith <tsmith@chef.io> | 2018-08-08 10:29:08 -0700 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-08-08 10:29:08 -0700 |
commit | 40ca707abee010a212e7f9adc18aa15d19b4bea8 (patch) | |
tree | 668788b97158e1494d992eaedd259eb9f556e2fe | |
parent | c0f5d99a1f82150c4cfc126dc9a11f03fb41b4c0 (diff) | |
parent | 0dd424966e2aebfd9052956c3888414d9d4574dc (diff) | |
download | ohai-40ca707abee010a212e7f9adc18aa15d19b4bea8.tar.gz |
Merge pull request #1227 from WheresAlice/configurable_timeout
Make the default shell_out timeout of 30 seconds configurable
-rw-r--r-- | lib/ohai/config.rb | 1 | ||||
-rw-r--r-- | lib/ohai/mixin/command.rb | 4 |
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/ohai/config.rb b/lib/ohai/config.rb index 085bcb9b..6029a26f 100644 --- a/lib/ohai/config.rb +++ b/lib/ohai/config.rb @@ -40,6 +40,7 @@ module Ohai default :run_all_plugins, false # optional plugins are the set of plugins that are marked optional but you wish to run. default :optional_plugins, [] + default :shellout_timeout, 30 end end diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb index f1236754..eb4844b5 100644 --- a/lib/ohai/mixin/command.rb +++ b/lib/ohai/mixin/command.rb @@ -28,8 +28,8 @@ module Ohai # accept a command and any of the mixlib-shellout options def shell_out(cmd, **options) options = options.dup - # unless specified by the caller timeout after 30 seconds - options[:timeout] ||= 30 + # unless specified by the caller timeout after configured timeout (default 30 seconds) + options[:timeout] ||= Ohai::Config.ohai[:shellout_timeout] unless RUBY_PLATFORM =~ /mswin|mingw32|windows/ options[:env] = options.key?(:env) ? options[:env].dup : {} options[:env]["PATH"] ||= ((ENV["PATH"] || "").split(":") + %w{/usr/local/sbin /usr/local/bin /usr/sbin /usr/bin /sbin /bin}).join(":") |