convert ProcessNotRunning to use System::Process
[god.git] / lib / god / conditions / process_not_running.rb
blobfeed2578ab8dbeec90184d2f9033fda36ff62f0b
1 module God
2   module Conditions
3     
4     class ProcessNotRunning < Condition
5       attr_accessor :pid_file
6       
7       def valid?
8         valid = true
9         valid &= complain("You must specify the 'pid_file' attribute for :process_not_running") if self.pid_file.nil?
10         valid
11       end
12     
13       def test
14         return false unless File.exist?(self.pid_file)
15         
16         pid = File.open(self.pid_file).read.strip
17         System::Process.new(pid).exists?
18       end
19     end
20     
21   end
22 end