added MemoryUsage and factored out ProcessCondition
[god.git] / lib / god / process_condition.rb
blob97f5e76cc478819e80d7648bcef2d4c22f02710f
1 module God
2   
3   class ProcessCondition < Condition
4     attr_accessor :pid_file, :clean
5     
6     def initialize
7       self.pid_file = nil
8       self.clean = true
9     end
10   
11     def valid?
12       valid = true
13       valid = complain("You must specify the 'pid_file' attribute for :process_not_running") if self.pid_file.nil?
14       valid
15     end
16   
17     def test
18       File.exist?(self.pid_file)
19     end
20   
21     def before_start
22       if self.clean
23         File.delete(self.pid_file) rescue nil
24       end
25     end
26   end
27   
28 end