From 6a96fccf1bd87b148a2ea35e187c495cb2b61ec7 Mon Sep 17 00:00:00 2001 From: luke Date: Tue, 30 Aug 2005 01:46:43 +0000 Subject: adding file reread to master, although it is plenty hackish git-svn-id: https://reductivelabs.com/svn/puppet/trunk@611 980ebf18-57e1-0310-9a29-db15c13687c0 --- lib/puppet/server/fileserver.rb | 1 + lib/puppet/server/master.rb | 41 ++++++++++++++++++++++++++++++++++++++--- 2 files changed, 39 insertions(+), 3 deletions(-) (limited to 'lib/puppet') diff --git a/lib/puppet/server/fileserver.rb b/lib/puppet/server/fileserver.rb index f7a15e6b9..d25185476 100755 --- a/lib/puppet/server/fileserver.rb +++ b/lib/puppet/server/fileserver.rb @@ -184,6 +184,7 @@ class Server if @configstamp and FileTest.exists?(@config) if @configtimeout and @configstatted and (Time.now - @configstatted > @configtimeout) + @configstatted = Time.now tmp = File.stat(@config).ctime if tmp == @configstamp diff --git a/lib/puppet/server/master.rb b/lib/puppet/server/master.rb index b45f91210..dd16c788d 100644 --- a/lib/puppet/server/master.rb +++ b/lib/puppet/server/master.rb @@ -20,11 +20,12 @@ class Server # FIXME this should all be s/:File/:Manifest/g or something # build our AST @file = hash[:File] || Puppet[:manifest] - @parser = Puppet::Parser::Parser.new() - @parser.file = @file - @ast = @parser.parse hash.delete(:File) + @filestamp = nil + @filetimeout = hash[:FileTimeout] || 60 + parsefile + if hash[:Local] @local = hash[:Local] else @@ -39,6 +40,7 @@ class Server end def getconfig(facts, client = nil, clientip = nil) + parsefile if client #Puppet.warning request.inspect end @@ -84,6 +86,39 @@ class Server return CGI.escape(Marshal::dump(retobjects)) end end + + private + + def parsefile + if @filestamp and FileTest.exists?(@file) + if @filetimeout and @filestatted and + (Time.now - @filestatted > @filetimeout) + tmp = File.stat(@file).ctime + + @filestatted = Time.now + if tmp == @filestamp + return + else + Puppet.notice "Reloading file" + end + 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 + end + end + # should i be creating a new parser each time...? + @parser = Puppet::Parser::Parser.new() + @parser.file = @file + @ast = @parser.parse + + @filestamp = File.stat(@file).ctime + end end end end -- cgit