4

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
user664833
  • 18,397
  • 19
  • 91
  • 140

2 Answers2

2

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:

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

Hongli
  • 18,682
  • 15
  • 79
  • 107
0

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

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.

Community
  • 1
  • 1
catsby
  • 11,276
  • 3
  • 37
  • 37