Do apps running in Phusion Passenger need to reconnect ActiveRecord on fork?

家住魔仙堡 提交于 2019-12-06 14:48:31

问题


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

回答1:


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?



来源:https://stackoverflow.com/questions/12918163/do-apps-running-in-phusion-passenger-need-to-reconnect-activerecord-on-fork

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