lib/datacenter/process.rb in datacenter-0.1.2 vs lib/datacenter/process.rb in datacenter-0.2.0

- old
+ new

@@ -28,29 +28,22 @@ info[attribute] end end def alive? - shell.run("ls /proc | grep #{pid}") == pid.to_s + alive = !shell.run("ps -p #{pid} | grep #{pid}").empty? + Datacenter.logger.debug(self.class) { "pid: #{pid} - ALIVE: #{alive}" } if !alive + alive end - def stop - send_signal :QUIT if alive? + def send_signal(signal) + shell.run "kill -s #{signal} #{pid}" end - def kill - send_signal :KILL if alive? - while alive?; end - end - private attr_reader :shell - def send_signal(signal) - shell.run "kill -s #{signal} #{pid}" - end - def info @cache.fetch(:info) do ps = shell.run('ps aux').scan(/.*#{pid}.*/)[0].split Hash.new.tap do |info| status = Hash[proc_file(:status).split("\n").map{ |s| s.split(':').map(&:strip) }]