diff --git a/lib/db/index.js b/lib/db/index.js index a8986e8a..5eaa2833 100644 --- a/lib/db/index.js +++ b/lib/db/index.js @@ -49,8 +49,10 @@ function connect() { db.connect = (function() { var connection var queue = [] + var goingDown = false lifecycle.observe(function() { + goingDown = true if (connection) { return connection.close() } @@ -65,7 +67,9 @@ db.connect = (function() { log.warn('Connection closed') connection = null conn.removeListener('close', closeListener) - createConnection() + if (!goingDown) { + createConnection() + } }) queue.splice(0).forEach(function(resolver) {