ruby-on-rails – 为什么puma没有像Unicorn这样的`before_fork`
发布时间:2020-12-16 21:05:31 所属栏目:百科 来源:网络整理
导读:我刚接触Puma,之前曾在Unicorn工作过. Unicorn配置有一个before_fork和after_fork方法断开连接,然后在fork之后重新建立连接. 然而,彪马没有那个.它只有on_worker_boot,它在概念上类似于after_fork方法. Puma是否也利用工人流程的分支?在像Unicorn这样的分叉
我刚接触Puma,之前曾在Unicorn工作过.
Unicorn配置有一个before_fork和after_fork方法断开连接,然后在fork之后重新建立连接. 然而,彪马没有那个.它只有on_worker_boot,它在概念上类似于after_fork方法. Puma是否也利用工人流程的分支?在像Unicorn这样的分叉之前是否需要断开连接? 谢谢! 示例文件 配置/ unicorn.rb before_fork do |server,worker| # other settings if defined?(ActiveRecord::Base) ActiveRecord::Base.connection.disconnect! end end after_fork do |server,worker| # other settings if defined?(ActiveRecord::Base) ActiveRecord::Base.establish_connection end end 配置/ puma.rb on_worker_boot do # Worker specific setup for Rails 4.1+ # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot ActiveRecord::Base.establish_connection end 解决方法
事实上,它现在有这个功能:
https://github.com/puma/puma/pull/754
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |