Does phusion passenger use forking, and if so, where to set after_fork config?

一世执手 提交于 2019-12-10 17:43:38

问题


Does phusion passenger use forking? If so, where should I set an after_fork configuration, as recommended by Heroku for unicorn (re: Setting up PostGIS with Rails)?

From Heroku's docs:

Additionally, if unicorn or any other process forking code is used where the connection is re-established, make sure to override the adapter to postgis as well. For example:

# unicorn.rb
after_fork do |server, worker|
  if defined?(ActiveRecord::Base)
    config = Rails.application.config.database_configuration[Rails.env]
    config['adapter'] = 'postgis'
    ActiveRecord::Base.establish_connection(config)
  end
end

回答1:


Yes, Phusion Passenger does forking, almost exactly like how Unicorn does it. Unicorn's default behavior (preload_app off) is the same as Phusion Passenger's "direct spawning" (not default in Phusion Passenger). Unicorn's preload_app on is the same as Phusion Passenger's "smart spawning" (default in Phusion Passenger). Sources:

  • passenger_spawn_method documentation
  • Appendix C: Spawning methods explained

The latter also teaches you how to install an after-fork hook.




回答2:


Phusion Passenger is primarily multi-process; the Enterprise version can do both multi-process and multi-threaded.

  • Ruby on Rails Server options
  • http://blog.phusion.nl/2013/03/12/tuning-phusion-passengers-concurrency-settings/

I don't know if an after_fork type thing is needed with Passenger, because it's not Ruby doing the forking of the process, but I'm not 100% sure there.



来源:https://stackoverflow.com/questions/24180809/does-phusion-passenger-use-forking-and-if-so-where-to-set-after-fork-config

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!