On Jul 25, 2009, at 3:55 AM, Brice Figureau wrote:
> > The runit provider was broken when the daemontools provider > was enhanced.This patch aims to fix this. > > Signed-off-by: Brice Figureau <[email protected]> > --- > lib/puppet/provider/service/runit.rb | 10 ++++++++++ > spec/unit/provider/service/runit.rb | 14 +++++++++++++- > 2 files changed, 23 insertions(+), 1 deletions(-) > > diff --git a/lib/puppet/provider/service/runit.rb b/lib/puppet/ > provider/service/runit.rb > index 45713b2..b2c8900 100644 > --- a/lib/puppet/provider/service/runit.rb > +++ b/lib/puppet/provider/service/runit.rb > @@ -91,6 +91,16 @@ > Puppet::Type.type(:service).provide :runit, :parent => :daemontools do > [ command(:sv), "stop", self.service] > end > > + # relay to the startcmd > + def start > + enable unless enabled? > + ucommand( :start ) > + end > + > + def startcmd > + [ command(:sv), "start", self.service] > + end This second method is never used, I believe, if the first method exists. Basically, the 'base' provider allows you to specify a 'startcmd' which will be preferentially used, but if you override the 'start' method, then none of that happens. Part of my refactor was to remove all of those unnecessary and unused methods. > > # disable by removing the symlink so that runit > # doesn't restart our service behind our back > # note that runit doesn't need to perform a stop > diff --git a/spec/unit/provider/service/runit.rb b/spec/unit/ > provider/service/runit.rb > index b0c5dd8..4a7a238 100644 > --- a/spec/unit/provider/service/runit.rb > +++ b/spec/unit/provider/service/runit.rb > @@ -30,6 +30,8 @@ describe provider_class do > @resource.stubs(:[]).with(:path).returns @daemondir > @resource.stubs(:ref).returns "Service[myservice]" > > + @provider.stubs(:sv) > + > @provider.stubs(:resource).returns @resource > end > > @@ -58,8 +60,18 @@ describe provider_class do > end > > describe "when starting" do > - it "should call enable" 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) > + > + @provider.start > + end > + > + it "should execute external command 'sv start /etc/service/ > myservice'" do > + @provider.expects(:ucommand).with(:start).returns("") > @provider.start > end > end > -- > 1.6.0.2 > > > > -- Susskind's Rule of Thumb: Don't ask what they think. Ask what they do. --------------------------------------------------------------------- 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 -~----------~----~----~----~------~----~------~--~---
