Class: NginxStage::PidFile
- Inherits:
-
Object
- Object
- NginxStage::PidFile
- Defined in:
- lib/nginx_stage/pid_file.rb
Overview
A class to handle a PID file
Instance Attribute Summary collapse
-
#pid ⇒ Integer
readonly
Process id that describes this object.
-
#pid_path ⇒ String
readonly
Path of the PID file.
Instance Method Summary collapse
-
#initialize(pid_path) ⇒ PidFile
constructor
A new instance of PidFile.
-
#running_process? ⇒ Boolean
Whether the corresponding pid is a running process.
-
#to_s ⇒ String
Convert object to string.
Constructor Details
#initialize(pid_path) ⇒ PidFile
Returns a new instance of PidFile.
15 16 17 18 19 20 |
# File 'lib/nginx_stage/pid_file.rb', line 15 def initialize(pid_path) @pid_path = pid_path raise MissingPidFile, "missing PID file: #{pid_path}" unless File.exist?(pid_path) raise InvalidPidFile, "invalid PID file: #{pid_path}" unless File.file?(pid_path) @pid = File.read(pid_path).to_i end |
Instance Attribute Details
#pid ⇒ Integer (readonly)
Process id that describes this object
10 11 12 |
# File 'lib/nginx_stage/pid_file.rb', line 10 def pid @pid end |
#pid_path ⇒ String (readonly)
Path of the PID file
6 7 8 |
# File 'lib/nginx_stage/pid_file.rb', line 6 def pid_path @pid_path end |
Instance Method Details
#running_process? ⇒ Boolean
Whether the corresponding pid is a running process
24 25 26 27 28 29 |
# File 'lib/nginx_stage/pid_file.rb', line 24 def running_process? Process.getpgid @pid true rescue Errno::ESRCH false end |
#to_s ⇒ String
Convert object to string
33 34 35 |
# File 'lib/nginx_stage/pid_file.rb', line 33 def to_s pid_path.to_s end |