请不要在的Phusion乘客的需要运行的应用程序,以重新ActiveRecord的叉? [英] Do apps running in Phusion Passenger need to reconnect ActiveRecord on fork?

查看:137
本文介绍了请不要在的Phusion乘客的需要运行的应用程序,以重新ActiveRecord的叉?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每本文档:

<一个href="http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_smart_spawning_gotcha_1_unintentional_file_descriptor_sharing" rel="nofollow">http://www.modrails.com/documentation/Users%20guide%20Nginx.html#_smart_spawning_gotcha_1_unintentional_file_descriptor_sharing

套接字连接继续智能产卵操作之后被共享。上市的例子是Memcached的。

1是否有类似的重新连接的A​​ctiveRecord在这种情况下,也?是这样的:

  PhusionPassenger.on_event(:starting_worker_process)办|叉|
        如果分叉
            #我们在智能产卵模式。
            ActiveRecord.establish_connection(...)
        其他
            #我们在保守的产卵模式。我们不需要做任何事情。
        结束
结束
 

解决方案

乘客会自动重新建立。在创建一个新的工作进程连接到数据库,根据向导,所以你不应该这样做。

您遇到会导致您认为这可能不是这样什么麻烦?

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

解决方案

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?

这篇关于请不要在的Phusion乘客的需要运行的应用程序,以重新ActiveRecord的叉?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆