Class: Puppet::Application::Queue
- Inherits:
-
Puppet::Application
- Object
- Puppet::Application
- Puppet::Application::Queue
- Defined in:
- lib/puppet/application/queue.rb
Constant Summary
Constants inherited from Puppet::Application
Instance Attribute Summary collapse
-
#daemon ⇒ Object
Returns the value of attribute daemon.
Attributes inherited from Puppet::Application
Instance Method Summary collapse
- #main ⇒ Object
- #preinit ⇒ Object
- #setup ⇒ Object
-
#setup_logs ⇒ Object
Handle the logging settings.
Methods inherited from Puppet::Application
[], banner, clear!, clear?, controlled_run, exit, find, #handlearg, #help, #initialize, interrupted?, #name, option, option_parser_commands, #parse_options, restart!, restart_requested?, #run, #run_command, run_mode, #set_run_mode, should_not_parse_config, should_parse_config, #should_parse_config?, should_parse_config?, stop!, stop_requested?
Methods included from Util
activerecord_version, benchmark, chuser, classproxy, #execfail, #execpipe, execute, logmethods, memory, proxy, recmkdir, secure_open, symbolize, symbolizehash, symbolizehash!, synchronize_on, thinmark, #threadlock, which, withumask
Methods included from Util::POSIX
#get_posix_field, #gid, #idfield, #methodbyid, #methodbyname, #search_posix_field, #uid
Constructor Details
This class inherits a constructor from Puppet::Application
Instance Attribute Details
#daemon ⇒ Object
Returns the value of attribute daemon.
7 8 9 |
# File 'lib/puppet/application/queue.rb', line 7 def daemon @daemon end |
Instance Method Details
#main ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'lib/puppet/application/queue.rb', line 40 def main require 'puppet/indirector/catalog/queue' # provides Puppet::Indirector::Queue.subscribe Puppet.notice "Starting puppetqd #{Puppet.version}" Puppet::Resource::Catalog::Queue.subscribe do |catalog| # Once you have a Puppet::Resource::Catalog instance, calling save on it should suffice # to put it through to the database via its active_record indirector (which is determined # by the terminus_class = :active_record setting above) Puppet::Util.benchmark(:notice, "Processing queued catalog for #{catalog.name}") do begin catalog.save rescue => detail puts detail.backtrace if Puppet[:trace] Puppet.err "Could not save queued catalog for #{catalog.name}: #{detail}" end end end Thread.list.each { |thread| thread.join } end |
#preinit ⇒ Object
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/puppet/application/queue.rb', line 9 def preinit require 'puppet/daemon' @daemon = Puppet::Daemon.new @daemon.argv = ARGV.dup Puppet::Util::Log.newdestination(:console) # Do an initial trap, so that cancels don't get a stack trace. # This exits with exit code 1 Signal.trap(:INT) do $stderr.puts "Caught SIGINT; shutting down" exit(1) end # This is a normal shutdown, so code 0 Signal.trap(:TERM) do $stderr.puts "Caught SIGTERM; shutting down" exit(0) end { :verbose => false, :debug => false }.each do |opt,val| [opt] = val end end |
#setup ⇒ Object
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# File 'lib/puppet/application/queue.rb', line 72 def setup unless Puppet.features.stomp? raise ArgumentError, "Could not load the 'stomp' library, which must be present for queueing to work. You must install the required library." end setup_logs exit(Puppet.settings.print_configs ? 0 : 1) if Puppet.settings.print_configs? require 'puppet/resource/catalog' Puppet::Resource::Catalog.terminus_class = :active_record daemon.daemonize if Puppet[:daemonize] # We want to make sure that we don't have a cache # class set up, because if storeconfigs is enabled, # we'll get a loop of continually caching the catalog # for storage again. Puppet::Resource::Catalog.cache_class = nil end |
#setup_logs ⇒ Object
Handle the logging settings.
61 62 63 64 65 66 67 68 69 70 |
# File 'lib/puppet/application/queue.rb', line 61 def setup_logs if [:debug] or [:verbose] Puppet::Util::Log.newdestination(:console) if [:debug] Puppet::Util::Log.level = :debug else Puppet::Util::Log.level = :info end end end |