From 877115a1cba1f3b3919980088f4f43e8a5ce3938 Mon Sep 17 00:00:00 2001 From: John Bintz Date: Fri, 27 May 2011 15:28:28 -0400 Subject: [PATCH] more shell goodness --- lib/guard/rails.rb | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/guard/rails.rb b/lib/guard/rails.rb index 4b5e643..bce077f 100644 --- a/lib/guard/rails.rb +++ b/lib/guard/rails.rb @@ -30,12 +30,18 @@ module Guard end private + def pid_file + File.expand_path("tmp/pids/#{options[:environment]}.pid") + end + def start_rails - system %{rails s -d -e #{options[:environment]} -p #{options[:port]}} + system %{sh -c 'rails s -d -e #{options[:environment]} -p #{options[:port]} --pid #{pid_file}'} end def stop_rails - system %{sh -c '[[ -f tmp/pids/#{options[:environment]}.pid ]] && kill $(cat tmp/pids/#{options[:environment]}.pid)'} + if File.file?(pid_file) + system %{kill -INT #{File.read(pid_file).strip}} + end end end end