Why do I get application errors when I stop and restart my mongod service
If I cancel and restart my mongodb on the default port, I reconnect fine and there aren't any problems.
When I do so on my27018
port, it seems to reconnect in my bash window and I get this statement at the end of the restart:
initandlisten] waiting for connections on port 27018
websvr] web admin interface listening on port 28018
but when I r开发者_运维技巧un my app I get errors like
Operation failed with the following exception: connection closed
and
Operation failed with the following exception: Broken pipe - send(2)
:10:in `synchronize'
Mongoid creates a connection to the MongoDB process and then keeps this around for performance reasons. If the server goes down the connection is broken at the server end and the client can no longer send requests.
In your Mongoid configuration you can configure the connection to be retriable, so that failed connections will be retried in the even of failure.
max_retries_on_connection_failure [2]
The number in square brackets is the number of times to retry (with half second gap between each try) before raising an exception.
精彩评论