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 inherited from Chef::Application
#apply_extra_config_options, #check_license_acceptance, #chef_config, #chef_configfetcher, #configure_chef, #configure_encoding, #configure_log_location, #configure_logging, debug_stacktrace, #emit_warnings, exit!, fatal!, #force_force_logger, #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?
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.
320 321 322 |
# File 'lib/chef/application/base.rb', line 320 def chef_client_json @chef_client_json end |
Instance Method Details
#run_application ⇒ Object
Run the chef client, optionally daemonizing or looping at intervals.
346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 |
# File 'lib/chef/application/base.rb', line 346 def run_application if Chef::Config[:version] puts "#{ChefUtils::Dist::Infra::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
322 323 324 |
# File 'lib/chef/application/base.rb', line 322 def setup_application Chef::Daemon.change_privilege end |
#setup_signal_handlers ⇒ Object
326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 |
# File 'lib/chef/application/base.rb', line 326 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 |