lib/datacenter/process.rb in datacenter-0.4.3 vs lib/datacenter/process.rb in datacenter-0.4.4

- old
+ new

@@ -27,11 +27,20 @@ info[attribute] end end def alive? - alive = !shell.run("ps -p #{pid} | grep #{pid}").empty? + command = %Q{ + if [ -d "#{proc_dir}" ]; then + echo -n "true" + else + echo -n "false" + fi + } + + alive = shell.run(command) == 'true' + Datacenter.logger.info(self.class) { "pid: #{pid} - ALIVE: #{alive}" } if !alive alive end def send_signal(signal) @@ -60,11 +69,15 @@ end end end end + def proc_dir + File.join '/proc', pid.to_s + end + def proc_file(name) - filename = File.join '/proc', pid.to_s, name.to_s + filename = File.join proc_dir, name.to_s shell.run "cat #{filename}" end end end