From 297350ece99674dddf84e564b4603fca5727307c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20Gonz=C3=A1lez?= Date: Wed, 25 Sep 2019 16:29:34 +0200 Subject: [PATCH] F #3380: Add timeout support for hooks (#3766) --- src/hem/onehem-server.rb | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/hem/onehem-server.rb b/src/hem/onehem-server.rb index d78c43e246..154884c50a 100755 --- a/src/hem/onehem-server.rb +++ b/src/hem/onehem-server.rb @@ -139,10 +139,12 @@ module HEMHook command.concat(" #{params}") end + _timeout = timeout + if !remote? - LocalCommand.run(command, nil, stdin, nil) + LocalCommand.run(command, nil, stdin, _timeout) elsif !host.empty? - SSHCommand.run(command, host, nil, stdin, nil) + SSHCommand.run(command, host, nil, stdin, _timeout) else return -1 end @@ -176,6 +178,12 @@ module HEMHook astdin.zero? end + def timeout + return self['TEMPLATE/TIMEOUT'].to_i if !self['TEMPLATE/TIMEOUT'].nil? + + nil + end + # Generates a key for a given hook def key begin