Class: Chef::Application::Base Deprecated
- Inherits:
-
Chef::Application
- Object
- Chef::Application
- Chef::Application::Base
- Includes:
- Mixin::ShellOut, ChefConfig::Mixin::DotD, LicenseAcceptance::CLIFlags::MixlibCLI
- Defined in:
- lib/chef/application/base.rb
Overview
use Chef::Application::Client instead, this will be removed in Chef-16
This is a temporary class being used as a part of an effort to reduce duplication between Chef::Application::Client and Chef::Application::Solo.
If you are looking to make edits to the Client/Solo behavior please make changes here.
If you are looking to reference or subclass this class, use Chef::Application::Client instead. This base class will be removed once the work is complete and external code will break.
Constant Summary collapse
- SELF_PIPE =
Mimic self_pipe sleep from Unicorn to capture signals safely
[]
- IMMEDIATE_RUN_SIGNAL =
"1".freeze
- RECONFIGURE_SIGNAL =
"H".freeze
Instance Attribute Summary collapse
-
#chef_client_json ⇒ Object
readonly
Returns the value of attribute chef_client_json.
Instance Method Summary collapse
-
#run_application ⇒ Object
Run the chef client, optionally daemonizing or looping at intervals.
- #setup_application ⇒ Object
- #setup_signal_handlers ⇒ Object
Methods included from Mixin::ShellOut
apply_default_env, maybe_add_timeout, #shell_out, #shell_out!
Methods inherited from Chef::Application
#apply_extra_config_options, #auto_log_level?, #check_license_acceptance, #chef_config, #chef_configfetcher, #configure_chef, #configure_encoding, #configure_log_location, #configure_logging, #configure_stdout_logger, debug_stacktrace, #emit_warnings, exit!, fatal!, #initialize, #load_config_file, #logger, logger, normalize_exit_code, #reconfigure, #resolve_log_level, #run, #run_chef_client, #set_specific_recipes, use_separate_defaults?, #using_output_formatter?, #want_additional_logger?
Constructor Details
This class inherits a constructor from Chef::Application
Instance Attribute Details
#chef_client_json ⇒ Object (readonly)
Returns the value of attribute chef_client_json.
296 297 298 |
# File 'lib/chef/application/base.rb', line 296 def chef_client_json @chef_client_json end |
Instance Method Details
#run_application ⇒ Object
Run the chef client, optionally daemonizing or looping at intervals.
322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 |
# File 'lib/chef/application/base.rb', line 322 def run_application if Chef::Config[:version] puts "#{Chef::Dist::PRODUCT} version: #{::Chef::VERSION}" end if !Chef::Config[:client_fork] || Chef::Config[:once] begin # run immediately without interval sleep, or splay run_chef_client(Chef::Config[:specific_recipes]) rescue SystemExit raise rescue Exception => e Chef::Application.fatal!("#{e.class}: #{e.}", e) end else interval_run_chef_client end end |
#setup_application ⇒ Object
298 299 300 |
# File 'lib/chef/application/base.rb', line 298 def setup_application Chef::Daemon.change_privilege end |
#setup_signal_handlers ⇒ Object
302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 |
# File 'lib/chef/application/base.rb', line 302 def setup_signal_handlers super unless Chef::Platform.windows? SELF_PIPE.replace IO.pipe trap("USR1") do Chef::Log.info("SIGUSR1 received, will run now or after the current run") SELF_PIPE[1].putc(IMMEDIATE_RUN_SIGNAL) # wakeup master process from select end # Override the trap setup in the parent so we can avoid running reconfigure during a run trap("HUP") do Chef::Log.info("SIGHUP received, will reconfigure now or after the current run") SELF_PIPE[1].putc(RECONFIGURE_SIGNAL) # wakeup master process from select end end end |