Class: Daemons::Pid
- Inherits:
-
Object
- Object
- Daemons::Pid
- Defined in:
- lib/feed_updater/vendor/daemons/pid.rb
Class Method Summary collapse
-
.dir(dir_mode, dir, script) ⇒ Object
Returns the directory that should be used to write the pid file to depending on the given mode.
- .running?(pid, additional = nil) ⇒ Boolean
Instance Method Summary collapse
-
#cleanup ⇒ Object
Cleanup method.
-
#exists? ⇒ Boolean
Exists? method.
-
#initialize ⇒ Pid
constructor
Initialization method.
-
#pid ⇒ Object
Get method.
-
#pid=(p) ⇒ Object
Set method.
Constructor Details
#initialize ⇒ Pid
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.(dir) when :script return File.(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
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
#cleanup ⇒ Object
Cleanup method
50 51 |
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 50 def cleanup end |
#exists? ⇒ Boolean
Exists? method
54 55 56 |
# File 'lib/feed_updater/vendor/daemons/pid.rb', line 54 def exists? true end |
#pid ⇒ Object
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 |