lib/process/daemon.rb in process-daemon-0.1.0 vs lib/process/daemon.rb in process-daemon-0.3.0

- old
+ new

@@ -128,12 +128,32 @@ def shutdown # Interrupt all children processes, preferably to stop them so that they are not left behind. Process.kill(0, :INT) end + # Helper methods for static daemon instance + + def self.instance + @instance ||= self.new + end + + # Main entry point for command line: def self.daemonize(argv = ARGV) - @@instance ||= self.new - - Controller.daemonize(@@instance, argv) + Controller.daemonize(instance, argv) + end + + # Start the daemon instance: + def self.start + Controller.start(instance) + end + + # Stop the daemon instance: + def self.stop + Controller.stop(instance) + end + + # Get the status of the daemon instance, `:stopped`, `:running` or `:unknown`. + def self.status + ProcessFile.status(instance) end end end