diff options
Diffstat (limited to 'lib/puppet/parser')
-rw-r--r-- | lib/puppet/parser/interpreter.rb | 26 |
1 files changed, 22 insertions, 4 deletions
diff --git a/lib/puppet/parser/interpreter.rb b/lib/puppet/parser/interpreter.rb index b1cf4207c..942c417a2 100644 --- a/lib/puppet/parser/interpreter.rb +++ b/lib/puppet/parser/interpreter.rb @@ -10,7 +10,7 @@ require 'puppet/parser/scope' module Puppet module Parser class Interpreter - attr_accessor :ast + attr_accessor :ast, :filetimeout # just shorten the constant path a bit, using what amounts to an alias AST = Puppet::Parser::AST @@ -21,6 +21,9 @@ module Puppet end @file = hash[:Manifest] + @filetimeout = hash[:ParseCheck] || 15 + + @lastchecked = 0 if hash.include?(:UseNodes) @usenodes = hash[:UseNodes] @@ -38,6 +41,11 @@ module Puppet evaluate end + def parsedate + parsefiles() + @parsedate + end + # evaluate our whole tree def run(client, facts) parsefiles() @@ -124,14 +132,20 @@ module Puppet def parsefiles if defined? @parser - unless @parser.reparse? - return false + # Only check the files every 15 seconds or so, not on + # every single connection + if (Time.now - @lastchecked).to_i >= @filetimeout.to_i + unless @parser.reparse? + @lastchecked = Time.now + return false + end + else + return end end unless FileTest.exists?(@file) if @ast - Puppet.warning "Manifest %s has disappeared" % @file return else raise Puppet::Error, "Manifest %s must exist" % @file @@ -146,6 +160,10 @@ module Puppet @parser.file = @file @ast = @parser.parse + # Mark when we parsed, so we can check freshness + @parsedate = Time.now.to_i + @lastchecked = Time.now + # Reevaluate the config. This is what actually replaces the # existing scope. evaluate |