Skip to content

Instantly share code, notes, and snippets.

@steverandy
Created December 10, 2013 09:44
Show Gist options
  • Save steverandy/7888148 to your computer and use it in GitHub Desktop.
Save steverandy/7888148 to your computer and use it in GitHub Desktop.
before_fork do |server, worker|
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
old_pid = "#{server.config[: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 did our job for us
end
end
sleep 1
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment