diff options
author | Daniel DeLeo <dan@opscode.com> | 2010-10-07 17:01:46 -0700 |
---|---|---|
committer | Daniel DeLeo <dan@opscode.com> | 2010-10-07 17:01:46 -0700 |
commit | ef86c4b7a2fe63a30f6b7859ef509daf041226f3 (patch) | |
tree | a7ba4c036e0f0fefbaa68e1cc855fa069721a86f | |
parent | 6b8093e07d352e2085504d5fdf281603cbc0ab39 (diff) | |
download | chef-ef86c4b7a2fe63a30f6b7859ef509daf041226f3.tar.gz |
[CHEF-1746] allow the client to loop when running in foreground
also, provide the --once option to force it to run once and exit with no
splay and no run interval
-rw-r--r-- | chef/lib/chef/application/client.rb | 9 | ||||
-rw-r--r-- | chef/spec/unit/application/client_spec.rb | 14 |
2 files changed, 19 insertions, 4 deletions
diff --git a/chef/lib/chef/application/client.rb b/chef/lib/chef/application/client.rb index a20eff84d9..4d8addd9af 100644 --- a/chef/lib/chef/application/client.rb +++ b/chef/lib/chef/application/client.rb @@ -89,6 +89,11 @@ class Chef::Application::Client < Chef::Application :description => "Run chef-client periodically, in seconds", :proc => lambda { |s| s.to_i } + option :once, + :long => "--short", + :description => "Cancel any interval or splay options, run chef once and exit", + :boolean => true + option :json_attribs, :short => "-j JSON_ATTRIBS", :long => "--json-attributes JSON_ATTRIBS", @@ -149,7 +154,9 @@ class Chef::Application::Client < Chef::Application if Chef::Config[:daemonize] Chef::Config[:interval] ||= 1800 - else + end + + if Chef::Config[:once] Chef::Config[:interval] = nil Chef::Config[:splay] = nil end diff --git a/chef/spec/unit/application/client_spec.rb b/chef/spec/unit/application/client_spec.rb index fd71d90034..843dea355f 100644 --- a/chef/spec/unit/application/client_spec.rb +++ b/chef/spec/unit/application/client_spec.rb @@ -46,16 +46,24 @@ describe Chef::Application::Client, "reconfigure" do end end - describe "when in client mode and splay has been set" do + describe "when configured to run once" do before do + Chef::Config[:once] = true Chef::Config[:daemonize] = false Chef::Config[:splay] = 60 + Chef::Config[:interval] = 1800 end - it "should ignore splay in client mode" do + it "ignores the splay" do @app.reconfigure - Chef::Config.splay.should == nil + Chef::Config.splay.should be_nil end + + it "forces the interval to nil" do + @app.reconfigure + Chef::Config.interval.should be_nil + end + end describe "when the json_attribs configuration option is specified" do |