Created
September 14, 2012 20:58
-
-
Save nthj/3724764 to your computer and use it in GitHub Desktop.
Automatically kill zombie Thin servers when booting up a rails server
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
# script/rails | |
# This command will automatically be run when you run "rails" with Rails 3 gems installed from the root of your application. | |
# Automatically kill zombie Thin servers when booting up a rails server | |
if ENV['RACK_ENV'] == 'development' && pid = `ps -ef | grep thin | grep -v grep | sort -r | sed -n 2p | awk '{print $2}'` | |
puts "=> Killing existing server with pid #{pid}" | |
`kill -9 #{pid}` | |
end | |
APP_PATH = File.expand_path('../../config/application', __FILE__) | |
require File.expand_path('../../config/boot', __FILE__) | |
require 'rails/commands' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment