diff options
Diffstat (limited to 'server.ts')
-rw-r--r-- | server.ts | 15 |
1 files changed, 9 insertions, 6 deletions
@@ -40,12 +40,16 @@ if (errorMessage !== null) { | |||
40 | // ----------- Database ----------- | 40 | // ----------- Database ----------- |
41 | // Do not use barrels because we don't want to load all modules here (we need to initialize database first) | 41 | // Do not use barrels because we don't want to load all modules here (we need to initialize database first) |
42 | import { logger } from './server/helpers/logger' | 42 | import { logger } from './server/helpers/logger' |
43 | |||
43 | // Initialize database and models | 44 | // Initialize database and models |
44 | import { initDatabase } from './server/initializers/database' | 45 | import { initDatabaseModels } from './server/initializers/database' |
45 | initDatabase(false).then(() => onDatabaseInitDone()) | 46 | import { migrate } from './server/initializers/migrator' |
47 | migrate() | ||
48 | .then(() => initDatabaseModels(false)) | ||
49 | .then(() => onDatabaseInitDone()) | ||
46 | 50 | ||
47 | // ----------- PeerTube modules ----------- | 51 | // ----------- PeerTube modules ----------- |
48 | import { migrate, installApplication } from './server/initializers' | 52 | import { installApplication } from './server/initializers' |
49 | import { activitypubHttpJobScheduler, transcodingJobScheduler, VideosPreviewCache } from './server/lib' | 53 | import { activitypubHttpJobScheduler, transcodingJobScheduler, VideosPreviewCache } from './server/lib' |
50 | import { apiRouter, clientsRouter, staticRouter, servicesRouter, webfingerRouter, activityPubRouter } from './server/controllers' | 54 | import { apiRouter, clientsRouter, staticRouter, servicesRouter, webfingerRouter, activityPubRouter } from './server/controllers' |
51 | 55 | ||
@@ -154,9 +158,8 @@ app.use(function (err, req, res, next) { | |||
154 | 158 | ||
155 | function onDatabaseInitDone () { | 159 | function onDatabaseInitDone () { |
156 | const port = CONFIG.LISTEN.PORT | 160 | const port = CONFIG.LISTEN.PORT |
157 | // Run the migration scripts if needed | 161 | |
158 | migrate() | 162 | installApplication() |
159 | .then(() => installApplication()) | ||
160 | .then(() => { | 163 | .then(() => { |
161 | // ----------- Make the server listening ----------- | 164 | // ----------- Make the server listening ----------- |
162 | server.listen(port, () => { | 165 | server.listen(port, () => { |