1

Per this documentation:

http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_smart_spawning_gotcha_1_unintentional_file_descriptor_sharing

Socket connections continue to be shared after a Smart spawn operation. The example listed is for Memcached.

Does one have to similarly reconnect ActiveRecord in this case as well? Something like:

PhusionPassenger.on_event(:starting_worker_process) do |forked|
        if forked
            # We're in smart spawning mode.
            ActiveRecord.establish_connection(...)
        else
            # We're in conservative spawning mode. We don't need to do anything.
        end
end
esilver
  • 27,713
  • 23
  • 122
  • 168

1 Answers1

0

passenger automatically reestablishes the connection to the database upon creating a new worker process, according to the guide, so you shouldn't have to do that.

Are you experiencing any trouble that would lead you to believe this might not be the case?

Tinco
  • 597
  • 3
  • 14
  • I am not experiencing any trouble. I just wanted to confirm this was the case. Could you point me to the part of the guide that says this? I am looking at http://www.modrails.com/documentation/Users%20guide%20Nginx.html and don't see anything in there about this. – esilver Oct 19 '12 at 20:26
  • It says so right below the link you posted, underneath the code exampe it says "Note that ..." Perhaps it could some more emphasis :) – Tinco Oct 21 '12 at 10:38
  • The latest documentation for this is here: https://www.phusionpassenger.com/library/indepth/ruby/spawn_methods/#am-i-responsible-for-reestablishing-database-connections-after-the-preloader-has-forked-a-child-process – esilver Dec 18 '17 at 03:07