Class: Daemons::Pid

Inherits:
Object
  • Object
show all
Defined in:
lib/feed_updater/vendor/daemons/pid.rb

Direct Known Subclasses

PidFile, PidMem

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initializePid

Initialization method



37
38
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 37

def initialize
end

Class Method Details

.dir(dir_mode, dir, script) ⇒ Object

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.



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 20

def Pid.dir(dir_mode, dir, script)
  # nil script parameter is allowed so long as dir_mode is not :script
  return nil if dir_mode == :script && script.nil?                         
  
  case dir_mode
    when :normal
      return File.expand_path(dir)
    when :script
      return File.expand_path(File.join(File.split(script)[0],dir))
    when :system  
      return '/var/run'
    else
      raise Error.new("pid file mode '#{dir_mode}' not implemented")
  end
end

.running?(pid, additional = nil) ⇒ Boolean

Returns:

  • (Boolean)


6
7
8
9
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 6

def Pid.running?(pid, additional = nil)
  output = `ps ax`
  return (/#{pid} / =~ output and (additional ? /#{additional}/ =~ output : true))
end

Instance Method Details

#cleanupObject

Cleanup method



50
51
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 50

def cleanup
end

#exists?Boolean

Exists? method

Returns:

  • (Boolean)


54
55
56
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 54

def exists?
  true
end

#pidObject

Get method



42
43
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 42

def pid
end

#pid=(p) ⇒ Object

Set method



46
47
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 46

def pid=(p)
end