summaryrefslogtreecommitdiffstats
path: root/lib/puppet.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-24 06:01:58 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-01-24 06:01:58 +0000
commitae2575b45de1e8f4c0ec956cebe0eed2bafbcf57 (patch)
tree9c2b7c839087c285c228374f525315e55c392a34 /lib/puppet.rb
parent18e8e74a2e3b4c5d092fc0aae38bbc5455d4db48 (diff)
downloadpuppet-ae2575b45de1e8f4c0ec956cebe0eed2bafbcf57.tar.gz
puppet-ae2575b45de1e8f4c0ec956cebe0eed2bafbcf57.tar.xz
puppet-ae2575b45de1e8f4c0ec956cebe0eed2bafbcf57.zip
Adding the event-loop stuff to the repository and switching to using it. Also, breaking many classes out into their own class files.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@848 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet.rb')
-rw-r--r--lib/puppet.rb61
1 files changed, 23 insertions, 38 deletions
diff --git a/lib/puppet.rb b/lib/puppet.rb
index b092dd7e2..2e1a88e66 100644
--- a/lib/puppet.rb
+++ b/lib/puppet.rb
@@ -1,4 +1,5 @@
require 'singleton'
+require 'puppet/event-loop'
require 'puppet/log'
require 'puppet/util'
@@ -85,7 +86,7 @@ PUPPETVERSION = '0.11.2'
:statedir => [:puppetvar, "state"],
:rundir => [:puppetvar, "run"],
- # then the files},
+ # then the files,
:manifestdir => [:puppetconf, "manifests"],
:manifest => [:manifestdir, "site.pp"],
:localconfig => [:puppetconf, "localconfig"],
@@ -109,6 +110,7 @@ PUPPETVERSION = '0.11.2'
:parseonly => false,
:puppetport => 8139,
:masterport => 8140,
+ :runinterval => 60,
}
# If we're running the standalone puppet process as a non-root user,
@@ -181,47 +183,30 @@ PUPPETVERSION = '0.11.2'
end
end
- def self.asuser(user)
- # FIXME this should use our user object, since it already knows how
- # to find users and such
- require 'etc'
-
- begin
- obj = Etc.getpwnam(user)
- rescue ArgumentError
- raise Puppet::Error, "User %s not found"
- end
-
- uid = obj.uid
-
- olduid = nil
- if Process.uid != uid
- olduid = Process.uid
- Process.euid = uid
- end
-
- retval = yield
-
-
- if olduid
- Process.euid = olduid
- end
-
- return retval
+ # Start our event loop. This blocks, waiting for someone, somewhere,
+ # to generate events of some kind.
+ def self.start
+ #Puppet.info "Starting loop"
+ EventLoop.current.run
end
- def self.join
- return unless defined? @threads
- @threads.each { |th| th.join }
- end
-
- def self.newthread
- @threads ||= []
- @threads << Thread.new {
- yield
- }
+ # Create the timer that our different objects (uh, mostly the client)
+ # check.
+ def self.timer
+ unless defined? @timer
+ #Puppet.info "Interval is %s" % Puppet[:runinterval]
+ #@timer = EventLoop::Timer.new(:interval => Puppet[:runinterval])
+ @timer = EventLoop::Timer.new(
+ :interval => Puppet[:runinterval],
+ :tolerance => 1,
+ :start? => true
+ )
+ EventLoop.current.monitor_timer @timer
+ end
+ @timer
end
+ # Store a new default value.
def self.setdefault(param,value)
if value.is_a?(Array)
if value[0].is_a?(Symbol)