class Process::Daemon::ProcessFile
This module controls the storage and retrieval of process id files.
def self.cleanup(daemon)
def self.cleanup(daemon) clear(daemon) unless running(daemon) end
def self.clear(daemon)
def self.clear(daemon) if File.exist? daemon.process_file_path FileUtils.rm(daemon.process_file_path) end end
def self.recall(daemon)
def self.recall(daemon) File.read(daemon.process_file_path).to_i rescue nil end
def self.running(daemon)
def self.running(daemon) pid = recall(daemon) return false if pid == nil gpid = Process.getpgid(pid) rescue nil return gpid != nil ? true : false end
def self.status(daemon)
This function returns the status of the daemon. This can be one of +:running+, +:unknown+ (pid file exists but no
def self.status(daemon) if File.exist? daemon.process_file_path return ProcessFile.running(daemon) ? :running : :unknown else return :stopped end end
def self.store(daemon, pid)
def self.store(daemon, pid) File.write(daemon.process_file_path, pid) end