Skip to content

Instantly share code, notes, and snippets.

@davinmsu
Created August 28, 2015 17:45
Show Gist options
  • Save davinmsu/32ba7638d99434b2383c to your computer and use it in GitHub Desktop.
Save davinmsu/32ba7638d99434b2383c to your computer and use it in GitHub Desktop.
GC.copy_on_write_friendly = true if GC.respond_to? :copy_on_write_friendly=
before_exec do |_|
ENV['BUNDLE_GEMFILE'] = "#{@dir}/Gemfile"
end
before_fork do |server, _|
old_pid = "#{server.config[:pid]}.oldbin"
if File.exist?(old_pid) && server.pid != old_pid
begin
Process.kill('QUIT', File.read(old_pid).to_i)
rescue Errno::ENOENT, Errno::ESRCH
end
end
end
after_fork do |_, _|
Rails.cache.reset if Rails.cache.respond_to? :reset
defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment