【问题标题】:Why does puma not have a `before_fork` method like Unicorn?为什么 puma 没有像 Unicorn 这样的 `before_fork` 方法?
【发布时间】:2015-09-12 00:20:11
【问题描述】:

我刚开始与 Puma 合作,之前曾与 Unicorn 合作过。

Unicorn 配置有一个 before_fork 和 after_fork 方法断开连接,然后在分叉后重新建立。

但是,彪马没有。它只有on_worker_boot,在概念上类似于after_fork 方法。

Puma 不也利用工作进程的分叉吗?像 Unicorn 一样分叉前不需要断开连接吗?

谢谢!

示例文件

config/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

config/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

【问题讨论】:

    标签: ruby-on-rails fork unicorn puma


    【解决方案1】:

    其实它现在有了这个功能:https://github.com/puma/puma/pull/754

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-12-02
      • 1970-01-01
      • 2013-07-27
      • 2011-04-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多