summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWheresAlice <WheresAlice@users.noreply.github.com>2018-08-04 20:11:03 +0100
committerWheresAlice <WheresAlice@users.noreply.github.com>2018-08-06 16:28:35 +0100
commit14dc5700fb7e6c66514414fc4fb861c0d7cb50e6 (patch)
tree1f13cbfc778f97ce169f8c747e3f601213bd4241
parent7e65f9a7eae6208362e117942dff8a9707d76895 (diff)
downloadohai-14dc5700fb7e6c66514414fc4fb861c0d7cb50e6.tar.gz
Make the default timeout of 30 seconds configurable
Signed-off-by: WheresAlice <WheresAlice@users.noreply.github.com>
-rw-r--r--lib/ohai/config.rb1
-rw-r--r--lib/ohai/mixin/command.rb4
2 files changed, 3 insertions, 2 deletions
diff --git a/lib/ohai/config.rb b/lib/ohai/config.rb
index 085bcb9b..4ee7dfb8 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 :timeout, 30
end
end
diff --git a/lib/ohai/mixin/command.rb b/lib/ohai/mixin/command.rb
index f1236754..073dae4d 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[: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(":")