Skip to content

Instantly share code, notes, and snippets.

@nthj
Created September 14, 2012 20:58
Show Gist options
  • Save nthj/3724764 to your computer and use it in GitHub Desktop.
Save nthj/3724764 to your computer and use it in GitHub Desktop.
Automatically kill zombie Thin servers when booting up a rails server
#!/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