Skip to content

Commit

Permalink
Don't attempt to reconnect to the db when we're dying.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorccu committed Feb 5, 2017
1 parent d08a541 commit a995a2f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/db/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
Expand All @@ -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) {
Expand Down

0 comments on commit a995a2f

Please sign in to comment.