0

I have got my resque setup process complete, tested successfully with a simple job. It is recommended to close ActiveRecord connection in the pool setup rake task and establish the connection on after_prefork to avoid stale connections before forking.

I now need to do this for mongoid, I can establish the connection by doing Mongoid.load! 'path_to_mongoid.yml' but I can't seem to find a way to close the connection, I tried disconnect, close methods but I don't know if they get reconnected or if it doesn't kill off the connection. I tried this in a rails console, I was able to test it with ActiveRecord doesn't work with mongoid.

4

1 回答 1

0

看起来disconnect确实杀死了 mongoid 连接,我很困惑,因为我期待在尝试使用活动记录时遇到类似的错误,但在需要时看起来像 mongoid 自动连接。

我使用 mongo 控制台验证了连接已被终止,您可以db.serverStatus().connections查看连接数并查看断开连接会减少当前连接。

于 2018-01-16T04:30:05.607 回答