Returns the directory that should be used to write the pid file to depending on the given mode.
Some modes may require an additionaly hint, others may determine the directory automatically.
If no valid directory is found, returns nil.
# File lib/daemons/pid.rb, line 63
63: def Pid.dir(dir_mode, dir, script)
64: # nil script parameter is allowed as long as dir_mode is not :script
65: return nil if dir_mode == :script && script.nil?
66:
67: case dir_mode
68: when :normal
69: return File.expand_path(dir)
70: when :script
71: return File.expand_path(File.join(File.dirname(script),dir))
72: when :system
73: return '/var/run'
74: else
75: raise Error.new("pid file mode '#{dir_mode}' not implemented")
76: end
77: end
Initialization method
# File lib/daemons/pid.rb, line 80
80: def initialize
81: end
# File lib/daemons/pid.rb, line 8
8: def Pid.running?(pid)
9: return false unless pid
10:
11: # Check if process is in existence
12: # The simplest way to do this is to send signal '0'
13: # (which is a single system call) that doesn't actually
14: # send a signal
15: begin
16: Process.kill(0, pid)
17: return true
18: rescue Errno::ESRCH
19: return false
20: rescue ::Exception # for example on EPERM (process exists but does not belong to us)
21: return true
22: #rescue Errno::EPERM
23: # return false
24: end
25: end
Cleanup method
# File lib/daemons/pid.rb, line 98
98: def cleanup
99: end
Exist? method
# File lib/daemons/pid.rb, line 102
102: def exist?
103: true
104: end
Disabled; run with --debug to generate this.
Generated with the Darkfish Rdoc Generator 1.1.6.