Class: Wakame::Monitor::Service::PidFileChecker
- Inherits:
-
ServiceChecker
- Object
- ServiceChecker
- Wakame::Monitor::Service::PidFileChecker
- Defined in:
- lib/wakame/monitor/service.rb
Instance Attribute Summary
Attributes inherited from ServiceChecker
#interval, #last_checked_at, #status, #svc_id, #timer
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(svc_id, svc_mon, pidpath, interval) ⇒ PidFileChecker
constructor
A new instance of PidFileChecker.
Methods inherited from ServiceChecker
Constructor Details
#initialize(svc_id, svc_mon, pidpath, interval) ⇒ PidFileChecker
Returns a new instance of PidFileChecker.
83 84 85 86 |
# File 'lib/wakame/monitor/service.rb', line 83 def initialize(svc_id, svc_mon, pidpath, interval) super(svc_id, svc_mon, interval) @pidpath = pidpath end |
Instance Method Details
#check ⇒ Object
88 89 90 91 92 93 94 95 96 |
# File 'lib/wakame/monitor/service.rb', line 88 def check return Wakame::Service::STATUS_OFFLINE unless File.exist?(@pidpath) #cmdstat = ::Open4.popen4("ps -p \"`cat '#{@pidpath}'`\" > /dev/null"){} #cmdstat.exitstatus == 0 ? Wakame::Service::STATUS_ONLINE : Wakame::Service::STATUS_OFFLINE cmdres = system("ps -p \"`cat '#{@pidpath}'`\" > /dev/null") # system() returns true or false. cmdres ? Wakame::Service::STATUS_ONLINE : Wakame::Service::STATUS_OFFLINE end |