fix: improve db error reporting for pg

This commit is contained in:
NGPixel 2019-12-30 16:45:25 -05:00
parent f1725159f7
commit 3092615c5e

View File

@ -138,7 +138,11 @@ module.exports = {
WIKI.logger.info('Database Connection Successful [ OK ]')
} catch (err) {
if (conAttempts < 10) {
WIKI.logger.error(`Database Connection Error: ${err.code} ${err.address}:${err.port}`)
if (err.code) {
WIKI.logger.error(`Database Connection Error: ${err.code} ${err.address}:${err.port}`)
} else {
WIKI.logger.error(`Database Connection Error: ${err.message}`)
}
WIKI.logger.warn(`Will retry in 3 seconds... [Attempt ${++conAttempts} of 10]`)
await new Promise(resolve => setTimeout(resolve, 3000))
await initTasks.connect()
@ -170,6 +174,7 @@ module.exports = {
// Perform init tasks
WIKI.logger.info(`Using database driver ${dbClient} for ${WIKI.config.db.type} [ OK ]`)
this.onReady = Promise.each(initTasksQueue, t => t()).return(true)
return {