Class: Pid
- Inherits:
-
Object
- Object
- Pid
- Defined in:
- lib/brisk/server/pid.rb
Class Method Summary collapse
- .alive?(pid) ⇒ Boolean
- .exists?(path) ⇒ Boolean
- .get(port) ⇒ Object
- .read(path) ⇒ Object
- .write(path, pid) ⇒ Object
Class Method Details
.alive?(pid) ⇒ Boolean
23 24 25 26 27 28 29 30 |
# File 'lib/brisk/server/pid.rb', line 23 def self.alive?(pid) begin Process.getpgid( pid.to_i ) true rescue Errno::ESRCH false end end |
.exists?(path) ⇒ Boolean
19 20 21 |
# File 'lib/brisk/server/pid.rb', line 19 def self.exists?(path) FileSystem.file_exists?("#{path}/tmp/pids/thin.pid") end |
.get(port) ⇒ Object
5 6 7 |
# File 'lib/brisk/server/pid.rb', line 5 def self.get(port) `sudo lsof -i tcp:#{port} | grep ruby | awk '{ print $2; }'` end |
.read(path) ⇒ Object
15 16 17 |
# File 'lib/brisk/server/pid.rb', line 15 def self.read(path) FileSystem.read("#{path}/tmp/pids/thin.pid") end |
.write(path, pid) ⇒ Object
9 10 11 12 13 |
# File 'lib/brisk/server/pid.rb', line 9 def self.write(path, pid) FileSystem.write("#{path}/pid.txt", pid) sleep(1) end |