Skip to content

Instantly share code, notes, and snippets.

@bdha
Created April 7, 2009 23:00
Show Gist options
  • Save bdha/91525 to your computer and use it in GitHub Desktop.
Save bdha/91525 to your computer and use it in GitHub Desktop.
--- /root/daemontools.rb.orig 2009-04-06 18:03:04.355682000 -0400
+++ daemontools.rb 2009-04-07 18:14:44.624793744 -0400
@@ -34,8 +34,7 @@
"""
- commands :svc => "/usr/bin/svc"
- commands :svstat => "/usr/bin/svstat"
+ commands :svc => "/usr/bin/svc", :svstat => "/usr/bin/svstat"
class << self
attr_writer :defpath
@@ -113,28 +112,33 @@
[ command(:svc), "-t", self.service]
end
- # The start command does nothing, service are automatically started
- # when enabled by svscan. But, forces an enable if necessary
- def start
- # to start make sure the sevice is enabled
- self.enable
- # start is then automatic
+ #def start
+ # self.enable
+ # texecute("start", [command(:svc), '-u', self.service] )
+ #end
+
+ def startcmd
+ Puppet.notice "Trying to start %s" % self.service
+ #self.enable
+ svc "-u", self.service
end
def status
begin
- output = svstat self.service
- return :running if output =~ /\bup\b/
+ output = svstat self.service
+ Puppet.notice "status says %s" % output
+ if output =~ /:(\s+)up/
+ return :running
+ end
rescue Puppet::ExecutionFailure => detail
raise Puppet::Error.new( "Could not get status for service %s: %s" % [ resource.ref, detail] )
end
+ Puppet.notice "%s is down" % self.service
return :stopped
end
- # unfortunately it is not possible
- # to stop without disabling the service
def stop
- self.disable
+ texecute("stop", [command(:svc), '-d', self.service] )
end
# disable by stopping the service
@@ -154,11 +158,18 @@
end
def enabled?
- FileTest.symlink?(self.service)
+ case self.status
+ when :running:
+ Puppet.notice "%s is %s" % [ self.service, self.status ]
+ return :true
+ else
+ return :false
+ end
end
def enable
File.symlink(self.daemon, self.service) if ! FileTest.symlink?(self.service)
+ self.start
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment