Skip to content

Instantly share code, notes, and snippets.

@bbg-deploy
Created December 3, 2013 23:40
Show Gist options
  • Select an option

  • Save bbg-deploy/7779760 to your computer and use it in GitHub Desktop.

Select an option

Save bbg-deploy/7779760 to your computer and use it in GitHub Desktop.
before_fork do |server, worker|
# No need for master process to hold a connection
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
# Kill off the old master
old_pid = "#{server.pid}.oldbin"
if File.exists?(old_pid) && server.pid != old_pid
begin
Process.kill("QUIT", File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
# someone else kiled off the old master
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment