diff options
author | Matt Wrock <matt@mattwrock.com> | 2015-11-05 08:33:38 -0800 |
---|---|---|
committer | Matt Wrock <matt@mattwrock.com> | 2015-11-05 08:33:38 -0800 |
commit | 20728416579f40c30e0a9c08bdfd86ecd7391cbe (patch) | |
tree | ab16e94ea652767bd5054cec5f9bb787e9151d90 /lib/chef/application | |
parent | f474f98750fe70e0264bf80793e578b739c08206 (diff) | |
download | chef-20728416579f40c30e0a9c08bdfd86ecd7391cbe.tar.gz |
windows service uses log file
location from config if none is given on commandline
Diffstat (limited to 'lib/chef/application')
-rw-r--r-- | lib/chef/application/windows_service.rb | 21 | ||||
-rw-r--r-- | lib/chef/application/windows_service_manager.rb | 5 |
2 files changed, 18 insertions, 8 deletions
diff --git a/lib/chef/application/windows_service.rb b/lib/chef/application/windows_service.rb index 2551582c3a..932f7e9c36 100644 --- a/lib/chef/application/windows_service.rb +++ b/lib/chef/application/windows_service.rb @@ -1,6 +1,6 @@ # # Author:: Christopher Maier (<maier@lambda.local>) -# Copyright:: Copyright (c) 2011 Opscode, Inc. +# Copyright:: Copyright (c) 2011-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -45,8 +45,7 @@ class Chef option :log_location, :short => "-L LOGLOCATION", :long => "--logfile LOGLOCATION", - :description => "Set the log file location", - :default => "#{ENV['SYSTEMDRIVE']}/chef/client.log" + :description => "Set the log file location" option :splay, :short => "-s SECONDS", @@ -60,6 +59,8 @@ class Chef :description => "Set the number of seconds to wait between chef-client runs", :proc => lambda { |s| s.to_i } + DEFAULT_LOG_LOCATION ||= "#{ENV['SYSTEMDRIVE']}/chef/client.log" + def service_init @service_action_mutex = Mutex.new @service_signal = ConditionVariable.new @@ -187,8 +188,9 @@ class Chef # Pass config params to the new process config_params = " --no-fork" config_params += " -c #{Chef::Config[:config_file]}" unless Chef::Config[:config_file].nil? - config_params += " -L #{Chef::Config[:log_location]}" unless Chef::Config[:log_location] == STDOUT + config_params += " -L #{resolve_log_location}" unless Chef::Config[:log_location] == STDOUT # Starts a new process and waits till the process exits + result = shell_out( "chef-client #{config_params}", :timeout => Chef::Config[:windows_service][:watchdog_timeout], @@ -235,7 +237,7 @@ class Chef # See application.rb for related comments. def configure_logging - Chef::Log.init(MonoLogger.new(Chef::Config[:log_location])) + Chef::Log.init(MonoLogger.new(resolve_log_location)) if want_additional_logger? configure_stdout_logger end @@ -264,6 +266,15 @@ class Chef Chef::Config[:log_level] == :auto end + # Check if we have a log location and it's not STDOUT + def resolve_log_location + if Chef::Config[:log_location] && Chef::Config[:log_location].is_a?(String) + Chef::Config[:log_location] + else + DEFAULT_LOG_LOCATION + end + end + # if log_level is `:auto`, convert it to :warn (when using output formatter) # or :info (no output formatter). See also +using_output_formatter?+ def resolve_log_level diff --git a/lib/chef/application/windows_service_manager.rb b/lib/chef/application/windows_service_manager.rb index 44526c1720..d969896025 100644 --- a/lib/chef/application/windows_service_manager.rb +++ b/lib/chef/application/windows_service_manager.rb @@ -1,6 +1,6 @@ # # Author:: Seth Chisamore (<schisamo@opscode.com>) -# Copyright:: Copyright (c) 2011 Opscode, Inc. +# Copyright:: Copyright (c) 2011-2015 Chef Software, Inc. # License:: Apache License, Version 2.0 # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -51,8 +51,7 @@ class Chef option :log_location, :short => "-L LOGLOCATION", :long => "--logfile LOGLOCATION", - :description => "Set the log file location for chef-service", - :default => "#{ENV['SYSTEMDRIVE']}/chef/client.log" + :description => "Set the log file location for chef-service" option :help, :short => "-h", |