summaryrefslogtreecommitdiff
path: root/lib/chef/application/solo.rb
diff options
context:
space:
mode:
Diffstat (limited to 'lib/chef/application/solo.rb')
-rw-r--r--lib/chef/application/solo.rb27
1 files changed, 25 insertions, 2 deletions
diff --git a/lib/chef/application/solo.rb b/lib/chef/application/solo.rb
index f0e578d5ef..cf7b5b4223 100644
--- a/lib/chef/application/solo.rb
+++ b/lib/chef/application/solo.rb
@@ -185,6 +185,8 @@ class Chef::Application::Solo < Chef::Application
Chef::Config[:interval] ||= 1800
end
+ Chef::Application.fatal!(unforked_interval_error_message) if !Chef::Config[:client_fork] && Chef::Config[:interval]
+
if Chef::Config[:recipe_url]
cookbooks_path = Array(Chef::Config[:cookbook_path]).detect{|e| e =~ /\/cookbooks\/*$/ }
recipes_path = File.expand_path(File.join(cookbooks_path, '..'))
@@ -209,6 +211,22 @@ class Chef::Application::Solo < Chef::Application
end
def run_application
+ if !Chef::Config[:client_fork] || Chef::Config[:once]
+ # Run immediately without interval sleep or splay
+ begin
+ run_chef_client(Chef::Config[:specific_recipes])
+ rescue SystemExit
+ raise
+ rescue Exception => e
+ Chef::Application.fatal!("#{e.class}: #{e.message}", 1)
+ end
+ else
+ interval_run_chef_client
+ end
+ end
+
+ private
+ def interval_run_chef_client
if Chef::Config[:daemonize]
Chef::Daemon.daemonize("chef-client")
end
@@ -244,8 +262,6 @@ class Chef::Application::Solo < Chef::Application
end
end
- private
-
def fetch_recipe_tarball(url, path)
Chef::Log.debug("Download recipes tarball from #{url} to #{path}")
File.open(path, 'wb') do |f|
@@ -254,4 +270,11 @@ class Chef::Application::Solo < Chef::Application
end
end
end
+
+ def unforked_interval_error_message
+ "Unforked chef-client interval runs are disabled in Chef 12." +
+ "\nConfiguration settings:" +
+ "#{"\n interval = #{Chef::Config[:interval]} seconds" if Chef::Config[:interval]}" +
+ "\nEnable chef-client interval runs by setting `:client_fork = true` in your config file or adding `--fork` to your command line options."
+ end
end