簡體   English   中英

為什么puma沒有像Unicorn這樣的`before_fork`方法?

[英]Why does puma not have a `before_fork` method like Unicorn?

我剛接觸Puma,之前曾在Unicorn工作過。

Unicorn配置有一個before_forkafter_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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM