Skip to content

Instantly share code, notes, and snippets.

@sideshowcoder
Created August 23, 2012 09:28
Show Gist options
  • Save sideshowcoder/3434628 to your computer and use it in GitHub Desktop.
Save sideshowcoder/3434628 to your computer and use it in GitHub Desktop.
Stop all thin servers on deploy
before 'foreman:restart', 'foreman:thin_stop'
namespace :foreman do
desc "Stop thin servers"
task :thin_stop, :roles => :app do
rake = fetch(:rake, 'rake')
rails_env = fetch(:rails_env, 'production')
run "cd '#{current_path}' && #{rake} thin:stop RAILS_ENV=#{rails_env}"
end
.
.
.
end
def find_and_kill name
Dir.glob("#{Rails.root}/tmp/pids/#{name}*").each do |file|
pid = File.read(file).to_i
puts "killing thin server with pid #{pid}"
Process.kill "INT", pid
end
end
namespace :thin do
desc "Stop thin servers"
task :stop => :environment do
find_and_kill "thin"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment