Skip to content

Commit 36e373e

Browse files
committed
fix: server not stop when app cannot connect to db
Signed-off-by: Raccoon <[email protected]>
1 parent e72bcfe commit 36e373e

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

app.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,12 +272,18 @@ models.sequelize.sync().then(function () {
272272
} else {
273273
throw new Error('server still not ready after db synced')
274274
}
275+
}).catch(err => {
276+
logger.error('Can\'t sync database');
277+
logger.error(err.stack)
278+
logger.error('Process will exit now.')
279+
process.exit(1)
275280
})
276281

277282
// log uncaught exception
278283
process.on('uncaughtException', function (err) {
279284
logger.error('An uncaught exception has occured.')
280285
logger.error(err)
286+
console.error(err)
281287
logger.error('Process will exit now.')
282288
process.exit(1)
283289
})

0 commit comments

Comments
 (0)