diff options
author | Claire McQuin <claire@getchef.com> | 2014-09-22 15:31:47 -0700 |
---|---|---|
committer | Claire McQuin <claire@getchef.com> | 2014-10-01 14:31:05 -0700 |
commit | 97b628a766d14a6a8fe6b3b2febb604a570e0cde (patch) | |
tree | 29f7f11b43250010a8e71c787c8d01eae0f1b97a /lib/chef/client.rb | |
parent | 00ecc94e206da3c09cf5dac8d698deaba970d8b2 (diff) | |
download | chef-97b628a766d14a6a8fe6b3b2febb604a570e0cde.tar.gz |
Disable unforked interval runs.
Clarify error message.
Move fork and interval logic to application (specs pending).
Clean code logic, fix specs.
Allow unforked client runs with daemonize or splay
Diffstat (limited to 'lib/chef/client.rb')
-rw-r--r-- | lib/chef/client.rb | 54 |
1 files changed, 3 insertions, 51 deletions
diff --git a/lib/chef/client.rb b/lib/chef/client.rb index 161ecddb0f..cc712a3f3e 100644 --- a/lib/chef/client.rb +++ b/lib/chef/client.rb @@ -191,54 +191,6 @@ class Chef end end - # Do a full run for this Chef::Client. Calls: - # * do_run - # - # This provides a wrapper around #do_run allowing the - # run to be optionally forked. - # === Returns - # boolean:: Return value from #do_run. Should always returns true. - def run - # win32-process gem exposes some form of :fork for Process - # class. So we are seperately ensuring that the platform we're - # running on is not windows before forking. - if(Chef::Config[:client_fork] && Process.respond_to?(:fork) && !Chef::Platform.windows?) - Chef::Log.info "Forking chef instance to converge..." - pid = fork do - [:INT, :TERM].each {|s| trap(s, "EXIT") } - client_solo = Chef::Config[:solo] ? "chef-solo" : "chef-client" - $0 = "#{client_solo} worker: ppid=#{Process.ppid};start=#{Time.new.strftime("%R:%S")};" - begin - Chef::Log.debug "Forked instance now converging" - do_run - rescue Exception => e - Chef::Log.error(e.to_s) - exit 1 - else - exit 0 - end - end - Chef::Log.debug "Fork successful. Waiting for new chef pid: #{pid}" - result = Process.waitpid2(pid) - handle_child_exit(result) - Chef::Log.debug "Forked instance successfully reaped (pid: #{pid})" - true - else - do_run - end - end - - def handle_child_exit(pid_and_status) - status = pid_and_status[1] - return true if status.success? - message = if status.signaled? - "Chef run process terminated by signal #{status.termsig} (#{Signal.list.invert[status.termsig]})" - else - "Chef run process exited unsuccessfully (exit code #{status.exitstatus})" - end - raise Exceptions::ChildConvergeError, message - end - # Instantiates a Chef::Node object, possibly loading the node's prior state # when using chef-client. Delegates to policy_builder # @@ -383,8 +335,6 @@ class Chef end end - private - # Do a full run for this Chef::Client. Calls: # # * run_ohai - Collect information about the system @@ -395,7 +345,7 @@ class Chef # # === Returns # true:: Always returns true. - def do_run + def run runlock = RunLock.new(Chef::Config.lockfile) runlock.acquire # don't add code that may fail before entering this section to be sure to release lock @@ -466,6 +416,8 @@ class Chef true end + private + def empty_directory?(path) !File.exists?(path) || (Dir.entries(path).size <= 2) end |