Parent

Daemons::Pid

Public Class Methods

dir(dir_mode, dir, script) click to toggle source

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 62
62:     def Pid.dir(dir_mode, dir, script)
63:       # nil script parameter is allowed as long as dir_mode is not :script
64:       return nil if dir_mode == :script && script.nil?                         
65:       
66:       case dir_mode
67:         when :normal
68:           return File.expand_path(dir)
69:         when :script
70:           return File.expand_path(File.join(File.dirname(script),dir))
71:         when :system  
72:           return '/var/run'
73:         else
74:           raise Error.new("pid file mode '#{dir_mode}' not implemented")
75:       end
76:     end
new() click to toggle source

Initialization method

    # File lib/daemons/pid.rb, line 79
79:     def initialize
80:     end
running?(pid) click to toggle source
    # File lib/daemons/pid.rb, line 7
 7:     def Pid.running?(pid)
 8:       return false unless pid
 9:       
10:       # Check if process is in existence
11:       # The simplest way to do this is to send signal '0'
12:       # (which is a single system call) that doesn't actually
13:       # send a signal
14:       begin
15:         Process.kill(0, pid)
16:         return true
17:       rescue Errno::ESRCH
18:         return false
19:       rescue ::Exception   # for example on EPERM (process exists but does not belong to us)
20:         return true
21:       #rescue Errno::EPERM
22:       #  return false
23:       end
24:     end

Public Instance Methods

cleanup() click to toggle source

Cleanup method

    # File lib/daemons/pid.rb, line 97
97:     def cleanup
98:     end
exist?() click to toggle source

Exist? method

     # File lib/daemons/pid.rb, line 101
101:     def exist?
102:       true
103:     end
pid() click to toggle source

Get method

    # File lib/daemons/pid.rb, line 84
84:     def pid
85:     end
pid=(p) click to toggle source

Set method

    # File lib/daemons/pid.rb, line 88
88:     def pid=(p)
89:     end
running?() click to toggle source

Check whether the process is running

    # File lib/daemons/pid.rb, line 92
92:     def running?
93:       return Pid.running?(pid())
94:     end

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.