diff options
author | Brice Figureau <brice-puppet@daysofwonder.com> | 2009-09-16 20:31:25 +0200 |
---|---|---|
committer | James Turnbull <james@lovedthanlost.net> | 2009-09-22 09:30:18 +1000 |
commit | a951163d3d8a52fff4f0340b4ed1e827f2399147 (patch) | |
tree | cedbcbf722303aa745532dd6cbf1f3bebd3fc705 | |
parent | 96b5087d4e8e6eb8e95f6dfab44163b486e1fd86 (diff) | |
download | puppet-a951163d3d8a52fff4f0340b4ed1e827f2399147.tar.gz puppet-a951163d3d8a52fff4f0340b4ed1e827f2399147.tar.xz puppet-a951163d3d8a52fff4f0340b4ed1e827f2399147.zip |
Fix #2642 - Runit provider rework
The runit provider was left broken after some work on daemontools
on which runit is based, and #2640 didn't override the
restart command, so daemontools once was called.
This patch aims to fix this provider and bring it on par with
daemontools.
Signed-off-by: Brice Figureau <brice-puppet@daysofwonder.com>
-rw-r--r-- | lib/puppet/provider/service/runit.rb | 18 | ||||
-rwxr-xr-x | spec/unit/provider/service/runit.rb | 16 |
2 files changed, 17 insertions, 17 deletions
diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/provider/service/runit.rb index 0182ec7d2..b313fc79c 100644 --- a/lib/puppet/provider/service/runit.rb +++ b/lib/puppet/provider/service/runit.rb @@ -66,10 +66,6 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do @servicedir end - def restartcmd - [ command(:sv), "restart", self.service] - end - def status begin output = sv "status", self.daemon @@ -82,23 +78,17 @@ Puppet::Type.type(:service).provide :runit, :parent => :daemontools do return :stopped end - # relay to the stopcmd def stop - ucommand( :stop ) - end - - def stopcmd - [ command(:sv), "stop", self.service] + sv "stop", self.service end - # relay to the startcmd def start enable unless enabled? == :true - ucommand( :start ) + sv "start", self.service end - def startcmd - [ command(:sv), "start", self.service] + def restart + sv "restart", self.service end # disable by removing the symlink so that runit diff --git a/spec/unit/provider/service/runit.rb b/spec/unit/provider/service/runit.rb index ad0ad67f1..dd8d0dac1 100755 --- a/spec/unit/provider/service/runit.rb +++ b/spec/unit/provider/service/runit.rb @@ -35,6 +35,10 @@ describe provider_class do @provider.stubs(:resource).returns @resource end + it "should have a restart method" do + @provider.should respond_to(:restart) + end + it "should have a restartcmd method" do @provider.should respond_to(:restartcmd) end @@ -62,7 +66,6 @@ describe provider_class do describe "when starting" do it "should enable the service if it is not enabled" do @provider.stubs(:sv) - @provider.stubs(:ucommand) @provider.expects(:enabled?).returns :false @provider.expects(:enable) @@ -72,18 +75,25 @@ describe provider_class do it "should execute external command 'sv start /etc/service/myservice'" do @provider.stubs(:enabled?).returns :true - @provider.expects(:ucommand).with(:start).returns("") + @provider.expects(:sv).with("start", "/etc/service/myservice") @provider.start end end describe "when stopping" do it "should execute external command 'sv stop /etc/service/myservice'" do - @provider.expects(:ucommand).with(:stop).returns("") + @provider.expects(:sv).with("stop", "/etc/service/myservice") @provider.stop end end + describe "when restarting" do + it "should call 'sv restart /etc/service/myservice'" do + @provider.expects(:sv).with("restart","/etc/service/myservice") + @provider.restart + end + end + describe "when enabling" do it "should create a symlink between daemon dir and service dir" do FileTest.stubs(:symlink?).returns(false) |