From 65a8d3f2c123349a2f461d0fc04e9e2f66e79d42 Mon Sep 17 00:00:00 2001 From: Mike Dirolf Date: Mon, 14 Sep 2009 15:22:41 -0400 Subject: [PATCH] documentation: add note on using phusion passenger --- README.rdoc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.rdoc b/README.rdoc index 4704262..cab0a34 100644 --- a/README.rdoc +++ b/README.rdoc @@ -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