Skip to content

Commit a48cff2

Browse files
authored
Merge pull request #9401 from mhashizume/PUP-1881/7.x/backport
(PUP-1881) Correct Windows runinterval behavior
2 parents 19caf04 + 67f657b commit a48cff2

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

ext/windows/service/daemon.rb

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,19 @@ def report_windows_event(type,id,message)
159159
end
160160
end
161161

162+
# Parses runinterval.
163+
#
164+
# @param puppet_path [String] The file path for the Puppet executable.
165+
# @return runinterval [Integer] How often to do a Puppet run, in seconds.
162166
def parse_runinterval(puppet_path)
163167
begin
164-
runinterval = %x{ #{puppet_path} config --section agent --log_level notice print runinterval }.to_i
165-
if runinterval == 0
168+
runinterval = %x(#{puppet_path} config --section agent --log_level notice print runinterval).chomp
169+
if runinterval == ''
166170
runinterval = 1800
167171
log_err("Failed to determine runinterval, defaulting to #{runinterval} seconds")
172+
else
173+
# Use Kernel#Integer because to_i will return 0 with non-numeric strings.
174+
runinterval = Integer(runinterval)
168175
end
169176
rescue Exception => e
170177
log_exception(e)

0 commit comments

Comments
 (0)