From 0cb51f3f7fb442b1b915523c93461b9a24febacb Mon Sep 17 00:00:00 2001 From: luke Date: Wed, 18 Jan 2006 21:30:56 +0000 Subject: Fixing a small checksumming bug, reorganizing the client stuff a bit, and adding freshness checking for the configuration, so the config is recompiled every time nor is it downloaded unless it has been recompiled git-svn-id: https://reductivelabs.com/svn/puppet/trunk@845 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/parser/interpreter.rb | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) (limited to 'lib/puppet/parser') 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 -- cgit