问题
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