Skip to content

Commit

Permalink
documentation: add note on using phusion passenger
Browse files Browse the repository at this point in the history
  • Loading branch information
Mike Dirolf committed Sep 14, 2009
1 parent 86d2bf7 commit 65a8d3f
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions README.rdoc
Expand Up @@ -119,6 +119,29 @@ Example code:

= Notes

== Using with Phusion Passenger

When passenger is in smart spawning mode you need to be sure that child
processes forked by passenger will create a new connection to the database.
activerecord-mongo-adapter handles this for you, so if you are using that
you shouldn't need to worry about it. Otherwise you'll either need to use
conservative spawning[http://www.modrails.org/documentation/Users%20guide.html#RailsSpawnMethod]
or handle reconnecting when passenger forks a new process:

if defined?(PhusionPassenger)
PhusionPassenger.on_event(:starting_worker_process) do |forked|
if forked
# Call db.connect_to_master to reconnect here
end
end
end

The above code should be put in _environment.rb_ or an initialization
script.

See this thread[http://groups.google.com/group/mongodb-user/browse_thread/thread/f31e2d23de38136a]
for more details on this issue.

== String Encoding

The BSON ("Binary JSON") format used to communicate with Mongo requires that
Expand Down

0 comments on commit 65a8d3f

Please sign in to comment.