Don't attempt to reconnect to the db when we're dying.

This commit is contained in:
Simo Kinnunen
2017-02-06 00:30:07 +09:00
parent d08a541bd2
commit a995a2f823

View File

@@ -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) {