+1

On Sep 16, 2009, at 11:32 AM, Brice Figureau wrote:

>
> 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 <[email protected]>
> ---
> lib/puppet/provider/service/runit.rb |   18 ++++--------------
> 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 0182ec7..b313fc7 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 ad0ad67..dd8d0da 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)
> -- 
> 1.6.4
>
>
> >


-- 
On Bureaucracy....
     The Pythagorean theorem contains 24 words. Archimedes
Principle, 67. The Ten Commandments, 179. The American Declaration of
Independence, 300. And recent legislation in Europe concerning when
and where to smoke, 23,942. -- The European, June 23-29, 1995
---------------------------------------------------------------------
Luke Kanies | http://reductivelabs.com | http://madstop.com


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Puppet Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/puppet-dev?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to