aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-24 14:11:15 +0200
committerChocobozzz <me@florianbigard.com>2020-08-24 14:11:15 +0200
commit74055dc882e484b217f398917a3cc24bf2ea8cbe (patch)
tree905fa5d78258d699c3dac4b22769fd209bafd8bc
parent8b6f0fd53d12faf54a58602a8bcfab05e8b5947b (diff)
downloadPeerTube-74055dc882e484b217f398917a3cc24bf2ea8cbe.tar.gz
PeerTube-74055dc882e484b217f398917a3cc24bf2ea8cbe.tar.zst
PeerTube-74055dc882e484b217f398917a3cc24bf2ea8cbe.zip
Fix tests
-rw-r--r--server.ts4
-rw-r--r--server/initializers/database.ts17
2 files changed, 13 insertions, 8 deletions
diff --git a/server.ts b/server.ts
index 1286cf521..e83fabb98 100644
--- a/server.ts
+++ b/server.ts
@@ -70,7 +70,9 @@ if (CONFIG.CSP.ENABLED) {
70// ----------- Database ----------- 70// ----------- Database -----------
71 71
72// Initialize database and models 72// Initialize database and models
73import { initDatabaseModels } from './server/initializers/database' 73import { initDatabaseModels, checkDatabaseConnectionOrDie } from './server/initializers/database'
74checkDatabaseConnectionOrDie()
75
74import { migrate } from './server/initializers/migrator' 76import { migrate } from './server/initializers/migrator'
75migrate() 77migrate()
76 .then(() => initDatabaseModels(false)) 78 .then(() => initDatabaseModels(false))
diff --git a/server/initializers/database.ts b/server/initializers/database.ts
index e05e7c335..a20cdacc3 100644
--- a/server/initializers/database.ts
+++ b/server/initializers/database.ts
@@ -77,13 +77,15 @@ const sequelizeTypescript = new SequelizeTypescript({
77 } 77 }
78}) 78})
79 79
80sequelizeTypescript.authenticate() 80function checkDatabaseConnectionOrDie () {
81 .then(() => logger.debug('Connection to PostgreSQL has been established successfully.')) 81 sequelizeTypescript.authenticate()
82 .catch(err => { 82 .then(() => logger.debug('Connection to PostgreSQL has been established successfully.'))
83 83 .catch(err => {
84 logger.error('Unable to connect to PostgreSQL database.', { err }) 84
85 process.exit(-1) 85 logger.error('Unable to connect to PostgreSQL database.', { err })
86 }) 86 process.exit(-1)
87 })
88}
87 89
88async function initDatabaseModels (silent: boolean) { 90async function initDatabaseModels (silent: boolean) {
89 sequelizeTypescript.addModels([ 91 sequelizeTypescript.addModels([
@@ -140,6 +142,7 @@ async function initDatabaseModels (silent: boolean) {
140 142
141export { 143export {
142 initDatabaseModels, 144 initDatabaseModels,
145 checkDatabaseConnectionOrDie,
143 sequelizeTypescript 146 sequelizeTypescript
144} 147}
145 148