diff options
author | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-08-30 01:46:43 +0000 |
---|---|---|
committer | luke <luke@980ebf18-57e1-0310-9a29-db15c13687c0> | 2005-08-30 01:46:43 +0000 |
commit | 6a96fccf1bd87b148a2ea35e187c495cb2b61ec7 (patch) | |
tree | c32d0745f433ab28facd538184aa80d1c5e6d1b3 /lib/puppet | |
parent | cff3a5b6cf3867287e1d1d76100f5f7744faa383 (diff) | |
download | puppet-6a96fccf1bd87b148a2ea35e187c495cb2b61ec7.tar.gz puppet-6a96fccf1bd87b148a2ea35e187c495cb2b61ec7.tar.xz puppet-6a96fccf1bd87b148a2ea35e187c495cb2b61ec7.zip |
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
Diffstat (limited to 'lib/puppet')
-rwxr-xr-x | lib/puppet/server/fileserver.rb | 1 | ||||
-rw-r--r-- | lib/puppet/server/master.rb | 41 |
2 files changed, 39 insertions, 3 deletions
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 |