summaryrefslogtreecommitdiffstats
path: root/lib/puppet/parser/interpreter.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-18 21:30:56 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-18 21:30:56 +0000
commit0cb51f3f7fb442b1b915523c93461b9a24febacb (patch)
tree578660289fa846e32450ff36e6ea5d524e7ba180 /lib/puppet/parser/interpreter.rb
parentf49b1030fc6f81c1776e09d8ce5e9134c828a77a (diff)
downloadpuppet-0cb51f3f7fb442b1b915523c93461b9a24febacb.tar.gz
puppet-0cb51f3f7fb442b1b915523c93461b9a24febacb.tar.xz
puppet-0cb51f3f7fb442b1b915523c93461b9a24febacb.zip
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
Diffstat (limited to 'lib/puppet/parser/interpreter.rb')
-rw-r--r--lib/puppet/parser/interpreter.rb26
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