Reconnect ActiveRecord when forking in Unicorn

This commit is contained in:
Yorick Peterse 2017-02-10 14:13:22 +01:00
parent 0d48a34039
commit a7b35aaf98
No known key found for this signature in database
GPG Key ID: EDD30D2BEB691AC9
1 changed files with 5 additions and 0 deletions

View File

@ -80,6 +80,11 @@ define :unicorn_service, :rails_app => nil, :user => nil do
rescue Errno::ENOENT, Errno::ESRCH
end
end
ActiveRecord::Base.connection.disconnect! if defined?(ActiveRecord::Base)
EOS
after_fork <<-'EOS'
ActiveRecord::Base.establish_connection if defined?(ActiveRecord::Base)
EOS
owner "root"
group "root"