diff options
author | Michael V. O'Brien <michael@reductivelabs.com> | 2007-10-03 17:06:06 -0500 |
---|---|---|
committer | Michael V. O'Brien <michael@reductivelabs.com> | 2007-10-03 17:06:06 -0500 |
commit | 0b8893b3b8ffd391287a590b4f271edca70331da (patch) | |
tree | d95e932676c7d06310d20e0248e5bc4be89fa91b | |
parent | ed8fa9b3458cacd67d9bd023a2a319c351e76e95 (diff) | |
download | puppet-0b8893b3b8ffd391287a590b4f271edca70331da.tar.gz puppet-0b8893b3b8ffd391287a590b4f271edca70331da.tar.xz puppet-0b8893b3b8ffd391287a590b4f271edca70331da.zip |
Fixed #832. Added the '--no-daemonize' option to puppetd and puppetmasterd.
The default behavior of 'verbose' and 'debug' no longer cause puppetd and
puppetmasterd to not daemonize.
-rwxr-xr-x | bin/puppetd | 52 | ||||
-rwxr-xr-x | bin/puppetmasterd | 37 | ||||
-rw-r--r-- | lib/puppet.rb | 2 | ||||
-rw-r--r-- | lib/puppet/defaults.rb | 8 | ||||
-rw-r--r-- | lib/puppet/util/settings.rb | 2 |
5 files changed, 46 insertions, 55 deletions
diff --git a/bin/puppetd b/bin/puppetd index 8d112ca3a..6450d1806 100755 --- a/bin/puppetd +++ b/bin/puppetd @@ -8,7 +8,7 @@ # # = Usage # -# puppetd [-D|--daemonize] [-d|--debug] [--disable] [--enable] +# puppetd [-D|--daemonize|--no-daemonize] [-d|--debug] [--disable] [--enable] # [-h|--help] [--fqdn <host name>] [-l|--logdest syslog|<file>|console] # [-o|--onetime] [--serve <handler>] [-t|--test] # [-V|--version] [-v|--verbose] [-w|--waitforcert <seconds>] @@ -63,8 +63,10 @@ # '--genconfig'. # # daemonize:: -# Send the process into the background. This is the default unless -# +verbose+ or +debug+ is enabled. +# Send the process into the background. This is the default. +# +# no-daemonize:: +# Do not send the process into the background. # # debug:: # Enable full debugging. @@ -161,7 +163,6 @@ require 'getoptlong' options = [ [ "--centrallogging", GetoptLong::NO_ARGUMENT ], - [ "--daemonize", "-D", GetoptLong::NO_ARGUMENT ], [ "--disable", GetoptLong::NO_ARGUMENT ], [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], [ "--enable", GetoptLong::NO_ARGUMENT ], @@ -201,9 +202,7 @@ begin result.each { |opt,arg| case opt # First check to see if the argument is a valid configuration parameter; - # if so, set it. - when "--daemonize" - options[:daemonize] = true + # if so, set it. NOTE: there is a catch-all at the bottom for defaults.rb when "--disable" options[:disable] = true when "--serve" @@ -215,17 +214,7 @@ begin when "--enable" options[:enable] = true when "--test" - # Enable all of the most common test options. - Puppet.settings.handlearg("--ignorecache") - Puppet.settings.handlearg("--no-usecacheonfailure") - Puppet.settings.handlearg("--no-splay") - Puppet.settings.handlearg("--show_diff") - options[:onetime] = true - options[:waitforcert] = 0 - unless Puppet::Util::Log.level == :debug - Puppet::Util::Log.level = :info - end - Puppet::Util::Log.newdestination(:console) + options[:test] = true when "--centrallogging" options[:centrallogs] = true when "--help" @@ -276,6 +265,21 @@ end # Now parse the config Puppet.parse_config +if options[:test] + # Enable all of the most common test options. + Puppet.settings.handlearg("--ignorecache") + Puppet.settings.handlearg("--no-usecacheonfailure") + Puppet.settings.handlearg("--no-splay") + Puppet.settings.handlearg("--show_diff") + Puppet.settings.handlearg("--no-daemonize") + options[:onetime] = true + options[:waitforcert] = 0 + unless Puppet::Util::Log.level == :debug + Puppet::Util::Log.level = :info + end + Puppet::Util::Log.newdestination(:console) +end + Puppet.genconfig Puppet.genmanifest @@ -284,16 +288,6 @@ if Puppet[:noop] Puppet[:show_diff] = true end -# Default to daemonizing, but if verbose or debug is specified, -# default to staying in the foreground. -unless options.include?(:daemonize) - if Puppet::Util::Log.level == :debug or Puppet::Util::Log.level == :info - options[:daemonize] = false - else - options[:daemonize] = true - end -end - unless options[:setdest] Puppet::Util::Log.newdestination(:syslog) end @@ -330,7 +324,7 @@ server = nil # It'd be nice to daemonize later, but we have to daemonize before the # waitforcert happens. -if options[:daemonize] +if Puppet[:daemonize] client.daemonize end diff --git a/bin/puppetmasterd b/bin/puppetmasterd index 51c714b15..acbafa59c 100755 --- a/bin/puppetmasterd +++ b/bin/puppetmasterd @@ -7,7 +7,7 @@ # # = Usage # -# puppetmasterd [-D|--daemonize] [-d|--debug] [-h|--help] +# puppetmasterd [-D|--daemonize|--no-daemonize] [-d|--debug] [-h|--help] # [-l|--logdest <file>|console|syslog] [--nobucket] [--nonodes] # [-v|--verbose] [-V|--version] # @@ -28,11 +28,13 @@ # '--genconfig'. # # daemonize:: -# Send the process into the background. This is the default unless -# +verbose+ or +debug+ is enabled. +# Send the process into the background. This is the default. +# +# no-daemonize:: +# Do not send the process into the background. # # debug:: -# Enable full debugging. Causes the daemon not to go into the background. +# Enable full debugging. # # help:: # Print this help message. @@ -53,7 +55,7 @@ # Do not start the reports server. # # verbose:: -# Enable verbosity. Causes the daemon not to go into the background. +# Enable verbosity. # # version:: # Print the puppet version number and exit. @@ -82,7 +84,6 @@ require 'puppet' require 'puppet/sslcertificates' options = [ - [ "--daemonize", "-D", GetoptLong::NO_ARGUMENT ], [ "--debug", "-d", GetoptLong::NO_ARGUMENT ], [ "--help", "-h", GetoptLong::NO_ARGUMENT ], [ "--logdest", "-l", GetoptLong::REQUIRED_ARGUMENT ], @@ -117,8 +118,8 @@ options = { begin result.each { |opt,arg| case opt - when "--daemonize" - options[:daemonize] = true + # First check to see if the argument is a valid configuration parameter; + # if so, set it. NOTE: there is a catch-all at the bottom for defaults.rb when "--debug" options[:debug] = true when "--help" @@ -161,6 +162,9 @@ rescue GetoptLong::InvalidOption => detail exit(1) end +# Now parse the config +Puppet.parse_config + # Handle the logging settings. if options[:debug] or options[:verbose] if options[:debug] @@ -169,7 +173,7 @@ if options[:debug] or options[:verbose] Puppet::Util::Log.level = :info end - unless options[:daemonize] + unless Puppet[:daemonize] Puppet::Util::Log.newdestination(:console) options[:setdest] = true end @@ -179,24 +183,11 @@ unless options[:setdest] Puppet::Util::Log.newdestination(:syslog) end -# Now parse the config -Puppet.parse_config - Puppet.genconfig Puppet.genmanifest require 'etc' -# Default to daemonizing, but if verbose or debug is specified, -# default to staying in the foreground. -unless options.include?(:daemonize) - if Puppet::Util::Log.level == :debug or Puppet::Util::Log.level == :info - options[:daemonize] = false - else - options[:daemonize] = true - end -end - handlers = { :Status => {}, } @@ -288,7 +279,7 @@ if Puppet[:servertype] == "webrick" end Puppet.settraps -if options[:daemonize] +if Puppet[:daemonize] server.daemonize end diff --git a/lib/puppet.rb b/lib/puppet.rb index c1f31e467..538a3335f 100644 --- a/lib/puppet.rb +++ b/lib/puppet.rb @@ -117,6 +117,8 @@ module Puppet # Load all of the configuration parameters. require 'puppet/defaults' + # Prints the contents of a config file with the available config elements, or it + # prints a single value of a config element. def self.genconfig if Puppet[:configprint] != "" val = Puppet[:configprint] diff --git a/lib/puppet/defaults.rb b/lib/puppet/defaults.rb index f76ae9b84..6f44919e2 100644 --- a/lib/puppet/defaults.rb +++ b/lib/puppet/defaults.rb @@ -131,7 +131,11 @@ module Puppet :diff => ["diff", "Which diff command to use when printing differences between files."], :show_diff => [false, "Whether to print a contextual diff when files are being replaced. The diff is printed on stdout, so this option is meaningless unless you are running Puppet interactively. - This feature currently requires the ``diff/lcs`` Ruby library."] + This feature currently requires the ``diff/lcs`` Ruby library."], + :daemonize => { :default => true, + :desc => "Send the process into the background. This is the default.", + :short => "D" + } ) hostname = Facter["hostname"].value @@ -339,7 +343,7 @@ module Puppet :owner => "root", :mode => 0644, :desc => "The file in which puppetd stores a list of the classes - associated with the retrieved configuratiion. Can be loaded in + associated with the retrieved configuration. Can be loaded in the separate ``puppet`` executable using the ``--loadclasses`` option."}, :puppetdlog => { :default => "$logdir/puppetd.log", diff --git a/lib/puppet/util/settings.rb b/lib/puppet/util/settings.rb index 1478cd8a5..ab55fbd2b 100644 --- a/lib/puppet/util/settings.rb +++ b/lib/puppet/util/settings.rb @@ -562,7 +562,7 @@ class Puppet::Util::Settings return transport.to_configuration end - # Convert our list of objects into a configuration file. + # Convert our list of config elements into a configuration file. def to_config str = %{The configuration file for #{Puppet[:name]}. Note that this file is likely to have unused configuration parameters in it; any parameter that's |