stop rails when shutting down

This commit is contained in:
John Bintz 2011-05-27 14:58:20 -04:00
parent 1d9f43326c
commit 39052564a9
1 changed files with 15 additions and 2 deletions

View File

@ -17,13 +17,26 @@ module Guard
def run_all
Notifier.notify("Rails restarting on port #{options[:port]} in #{options[:environment]}", :title => "Restarting Rails...", :image => :pending)
system %{sh -c '[[ -f tmp/pids/#{options[:environment]}.pid ]] && kill $(cat tmp/pids/#{options[:environment]}.pid)'}
system %{rails s -d -e #{options[:environment]} -p #{options[:port]}}
stop_rails ; start_rails
end
def stop
Notifier.notify("Until next time...", :title => "Rails shutting down.", :image => :pending)
stop_rails
end
def run_on_change(paths)
run_all
end
private
def start_rails
system %{rails s -d -e #{options[:environment]} -p #{options[:port]}}
end
def stop_rails
system %{sh -c '[[ -f tmp/pids/#{options[:environment]}.pid ]] && kill $(cat tmp/pids/#{options[:environment]}.pid)'}
end
end
end