diff options
author | Avishai Ish-Shalom <avishai.ish-shalom@mail.huji.ac.il> | 2011-03-26 11:20:45 +0200 |
---|---|---|
committer | Bryan McLellan <btm@opscode.com> | 2011-06-01 15:19:46 -0700 |
commit | 139335d4aade5088844c6f785d42b477b0017ecf (patch) | |
tree | 40b53d9f0f3096437111b71a20b56d9af1ced240 | |
parent | 6a35965309a118a9a0ed20b11a225296067a4dc6 (diff) | |
download | chef-139335d4aade5088844c6f785d42b477b0017ecf.tar.gz |
Fixed CHEF-1424
-rw-r--r-- | chef/lib/chef/provider/service/upstart.rb | 6 | ||||
-rw-r--r-- | chef/spec/unit/provider/service/upstart_service_spec.rb | 6 |
2 files changed, 11 insertions, 1 deletions
diff --git a/chef/lib/chef/provider/service/upstart.rb b/chef/lib/chef/provider/service/upstart.rb index 447e72633e..3497737b49 100644 --- a/chef/lib/chef/provider/service/upstart.rb +++ b/chef/lib/chef/provider/service/upstart.rb @@ -141,7 +141,11 @@ class Chef if @new_resource.restart_command super else - run_command_with_systems_locale(:command => "/sbin/restart #{@new_resource.service_name}") + if @current_resource.running + run_command_with_systems_locale(:command => "/sbin/restart #{@new_resource.service_name}") + else + start_service + end end end diff --git a/chef/spec/unit/provider/service/upstart_service_spec.rb b/chef/spec/unit/provider/service/upstart_service_spec.rb index 2e1cd971e0..82e8c58e49 100644 --- a/chef/spec/unit/provider/service/upstart_service_spec.rb +++ b/chef/spec/unit/provider/service/upstart_service_spec.rb @@ -242,6 +242,12 @@ describe Chef::Provider::Service::Upstart do @provider.restart_service() end + it "should call '/sbin/start service_name' if restart_service is called for a stopped service" do + @current_resource.stub!(:running).and_return(false) + @provider.should_receive(:run_command_with_systems_locale).with({:command => "/sbin/start #{@new_resource.service_name}"}).and_return(0) + @provider.restart_service() + end + it "should call the reload command if one is specified" do @current_resource.stub!(:running).and_return(true) @new_resource.stub!(:reload_command).and_return("/sbin/rsyslog reloadyousillysally") |