diff options
author | Marc Chamberland <chamberland.marc@gmail.com> | 2020-05-09 22:58:18 -0400 |
---|---|---|
committer | Lance Albertson <lance@osuosl.org> | 2020-09-15 14:04:36 -0700 |
commit | ed48186831835be81b436a160bcf190a7756d473 (patch) | |
tree | d4ae8196171c57dc2e773e610997e5894e5cf019 /lib/chef/application/windows_service.rb | |
parent | f5bbe608321ce3bcfd2d4f17292cf8c1ff042893 (diff) | |
download | chef-ed48186831835be81b436a160bcf190a7756d473.tar.gz |
move dist implementation into chef-utils
Signed-off-by: Marc Chamberland <chamberland.marc@gmail.com>
Signed-off-by: Lance Albertson <lance@osuosl.org>
Diffstat (limited to 'lib/chef/application/windows_service.rb')
-rw-r--r-- | lib/chef/application/windows_service.rb | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb index 770a5644ca..49ab3d2855 100644 --- a/lib/chef/application/windows_service.rb +++ b/lib/chef/application/windows_service.rb @@ -29,7 +29,7 @@ require "socket" unless defined?(Socket) require "uri" unless defined?(URI) require "win32/daemon" require_relative "../mixin/shell_out" -require_relative "../dist" +require "chef-utils" class Chef class Application @@ -41,7 +41,7 @@ class Chef short: "-c CONFIG", long: "--config CONFIG", default: "#{Chef::Config.etc_chef_dir}/client.rb", - description: "The configuration file to use for #{Chef::Dist::PRODUCT} runs." + description: "The configuration file to use for #{ChefUtils::Dist::Infra::PRODUCT} runs." option :log_location, short: "-L LOGLOCATION", @@ -57,7 +57,7 @@ class Chef option :interval, short: "-i SECONDS", long: "--interval SECONDS", - description: "Set the number of seconds to wait between #{Chef::Dist::PRODUCT} runs.", + description: "Set the number of seconds to wait between #{ChefUtils::Dist::Infra::PRODUCT} runs.", proc: lambda { |s| s.to_i } DEFAULT_LOG_LOCATION ||= "#{Chef::Config.c_chef_dir}/client.log".freeze @@ -67,7 +67,7 @@ class Chef @service_signal = ConditionVariable.new reconfigure - Chef::Log.info("#{Chef::Dist::CLIENT} Service initialized") + Chef::Log.info("#{ChefUtils::Dist::Infra::CLIENT} Service initialized") end def service_main(*startup_parameters) @@ -79,7 +79,7 @@ class Chef # Grab the service_action_mutex to make a chef-client run @service_action_mutex.synchronize do - Chef::Log.info("Next #{Chef::Dist::CLIENT} run will happen in #{timeout} seconds") + Chef::Log.info("Next #{ChefUtils::Dist::Infra::CLIENT} run will happen in #{timeout} seconds") @service_signal.wait(@service_action_mutex, timeout) # Continue only if service is RUNNING @@ -96,7 +96,7 @@ class Chef # run chef-client only if service is in RUNNING state next if state != RUNNING - Chef::Log.info("#{Chef::Dist::CLIENT} service is starting a #{Chef::Dist::CLIENT} run...") + Chef::Log.info("#{ChefUtils::Dist::Infra::CLIENT} service is starting a #{ChefUtils::Dist::Infra::CLIENT} run...") run_chef_client rescue SystemExit => e # Do not raise any of the errors here in order to @@ -131,12 +131,12 @@ class Chef break else unless run_warning_displayed - Chef::Log.info("Currently a #{Chef::Dist::PRODUCT} run is happening on this system.") + Chef::Log.info("Currently a #{ChefUtils::Dist::Infra::PRODUCT} run is happening on this system.") Chef::Log.info("Service will stop when run is completed.") run_warning_displayed = true end - Chef::Log.trace("Waiting for #{Chef::Dist::PRODUCT} run...") + Chef::Log.trace("Waiting for #{ChefUtils::Dist::Infra::PRODUCT} run...") sleep 1 end end @@ -150,7 +150,7 @@ class Chef # since this is a PAUSE signal. if @service_action_mutex.locked? - Chef::Log.info("Currently a #{Chef::Dist::PRODUCT} run is happening.") + Chef::Log.info("Currently a #{ChefUtils::Dist::Infra::PRODUCT} run is happening.") Chef::Log.info("Service will pause once it's completed.") else Chef::Log.info("Service is pausing....") @@ -185,7 +185,7 @@ class Chef # The log_location and config_file of the parent process is passed to the new chef-client process. # We need to add the --no-fork, as by default it is set to fork=true. - Chef::Log.info "Starting #{Chef::Dist::CLIENT} in a new process" + Chef::Log.info "Starting #{ChefUtils::Dist::Infra::CLIENT} in a new process" # Pass config params to the new process config_params = " --no-fork" config_params += " -c #{Chef::Config[:config_file]}" unless Chef::Config[:config_file].nil? @@ -197,20 +197,20 @@ class Chef # Starts a new process and waits till the process exits result = shell_out( - "#{Chef::Dist::CLIENT}.bat #{config_params}", + "#{ChefUtils::Dist::Infra::CLIENT}.bat #{config_params}", timeout: Chef::Config[:windows_service][:watchdog_timeout], logger: Chef::Log ) Chef::Log.trace (result.stdout).to_s Chef::Log.trace (result.stderr).to_s rescue Mixlib::ShellOut::CommandTimeout => e - Chef::Log.error "#{Chef::Dist::CLIENT} timed out\n(#{e})" + Chef::Log.error "#{ChefUtils::Dist::Infra::CLIENT} timed out\n(#{e})" Chef::Log.error(<<-EOF) - Your #{Chef::Dist::CLIENT} run timed out. You can increase the time #{Chef::Dist::CLIENT} is given + Your #{ChefUtils::Dist::Infra::CLIENT} run timed out. You can increase the time #{ChefUtils::Dist::Infra::CLIENT} is given to complete by configuring windows_service.watchdog_timeout in your client.rb. EOF rescue Mixlib::ShellOut::ShellCommandFailed => e - Chef::Log.warn "Not able to start #{Chef::Dist::CLIENT} in new process (#{e})" + Chef::Log.warn "Not able to start #{ChefUtils::Dist::Infra::CLIENT} in new process (#{e})" rescue => e Chef::Log.error e ensure |