Created
August 23, 2012 09:28
-
-
Save sideshowcoder/3434628 to your computer and use it in GitHub Desktop.
Stop all thin servers on deploy
This file contains hidden or 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
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 |
This file contains hidden or 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
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