added MemoryUsage and factored out ProcessCondition
[god.git] / lib / god / conditions / process_not_running.rb
blobf9cb1d8e22b7da9b63a5915e77014d9bdf79a5dd
1 module God
2   module Conditions
3     
4     class ProcessNotRunning < ProcessCondition
5       def test
6         return false unless super
7         pid = File.open(self.pid_file).read.strip
8         process_running?(pid)
9       end
10         
11       private
12     
13       def process_running?(pid)
14         cmd_name = RUBY_PLATFORM =~ /solaris/i ? "args" : "command"
15         ps_output = `ps -o #{cmd_name}= -p #{pid}`
16         !ps_output.strip.empty?
17       end 
18     end
19     
20   end
21 end