title: How to handle Mongoose DB connection interruptions
body: <p>I've been evaluating Mongoose (an ORM for node.js which uses MongoDB for persistent storage).</p>
  
  <p>What I'd like to do is make sure that the app can run when the DB is not up when the app starts, and also handles the DB going down intelligently. </p>
  
  <p>Currently my test app which does not work in either case does this:</p>
  
  <pre><code>var mongoose_connection = mongoose.createConnection(DATABASE_URL, {server:{poolSize:4}});
  </code></pre>
  
  <p>Then I use that connection when making Models.</p>
  
  <p>In the case when the DB is down at the start of the app then any save() calls on instances silently fail with no error. If the DB comes back up they never get written.</p>
  
  <p>So I would need to detect that the connection never happened and have the app be able to tell that at runtime so that I can handle it somehow.</p>
  
  <p>When the DB goes down after the app has started though the save() calls still do not cause errors but they are queued and the written when the DB comes back. </p>
  
  <p>That seems fine except I'd like to hook into the API to get events when the DB is down and to query how many save's are queued. At some point I might have so many queued events that I would want to just stop making new ones and have the app back off.</p>