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 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
new() click to toggle source

Initialization method

    # File lib/daemons/pid.rb, line 80
80:     def initialize
81:     end
running?(pid) click to toggle source
    # 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

Public Instance Methods

cleanup() click to toggle source

Cleanup method

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

Exist? method

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

Get method

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

Set method

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

Check whether the process is running

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

Disabled; run with --debug to generate this.

[Validate]

Generated with the Darkfish Rdoc Generator 1.1.6.