diff options
-rw-r--r-- | server.ts | 53 | ||||
-rw-r--r-- | server/lib/emailer.ts | 2 |
2 files changed, 30 insertions, 25 deletions
@@ -58,7 +58,11 @@ import { initDatabaseModels } from './server/initializers/database' | |||
58 | import { migrate } from './server/initializers/migrator' | 58 | import { migrate } from './server/initializers/migrator' |
59 | migrate() | 59 | migrate() |
60 | .then(() => initDatabaseModels(false)) | 60 | .then(() => initDatabaseModels(false)) |
61 | .then(() => onDatabaseInitDone()) | 61 | .then(() => startApplication()) |
62 | .catch(err => { | ||
63 | logger.error('Cannot start application.', { err }) | ||
64 | process.exit(-1) | ||
65 | }) | ||
62 | 66 | ||
63 | // ----------- PeerTube modules ----------- | 67 | // ----------- PeerTube modules ----------- |
64 | import { installApplication } from './server/initializers' | 68 | import { installApplication } from './server/initializers' |
@@ -179,30 +183,29 @@ app.use(function (err, req, res, next) { | |||
179 | 183 | ||
180 | // ----------- Run ----------- | 184 | // ----------- Run ----------- |
181 | 185 | ||
182 | function onDatabaseInitDone () { | 186 | async function startApplication () { |
183 | const port = CONFIG.LISTEN.PORT | 187 | const port = CONFIG.LISTEN.PORT |
184 | 188 | ||
185 | installApplication() | 189 | await installApplication() |
186 | .then(() => { | 190 | |
187 | // ----------- Make the server listening ----------- | 191 | // Email initialization |
188 | server.listen(port, () => { | 192 | Emailer.Instance.init() |
189 | // Emailer initialization and then job queue initialization | 193 | await Emailer.Instance.checkConnectionOrDie() |
190 | Emailer.Instance.init() | 194 | |
191 | Emailer.Instance.checkConnectionOrDie() | 195 | await JobQueue.Instance.init() |
192 | .then(() => JobQueue.Instance.init()) | 196 | |
193 | 197 | // Caches initializations | |
194 | // Caches initializations | 198 | VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE) |
195 | VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE) | 199 | |
196 | 200 | // Enable Schedulers | |
197 | // Enable Schedulers | 201 | BadActorFollowScheduler.Instance.enable() |
198 | BadActorFollowScheduler.Instance.enable() | 202 | RemoveOldJobsScheduler.Instance.enable() |
199 | RemoveOldJobsScheduler.Instance.enable() | 203 | |
200 | 204 | // Redis initialization | |
201 | // Redis initialization | 205 | Redis.Instance.init() |
202 | Redis.Instance.init() | 206 | |
203 | 207 | // Make server listening | |
204 | logger.info('Server listening on port %d', port) | 208 | server.listen(port) |
205 | logger.info('Web server: %s', CONFIG.WEBSERVER.URL) | 209 | logger.info('Server listening on port %d', port) |
206 | }) | 210 | logger.info('Web server: %s', CONFIG.WEBSERVER.URL) |
207 | }) | ||
208 | } | 211 | } |
diff --git a/server/lib/emailer.ts b/server/lib/emailer.ts index 85cc725fa..d17749b9a 100644 --- a/server/lib/emailer.ts +++ b/server/lib/emailer.ts | |||
@@ -60,6 +60,8 @@ class Emailer { | |||
60 | async checkConnectionOrDie () { | 60 | async checkConnectionOrDie () { |
61 | if (!this.transporter) return | 61 | if (!this.transporter) return |
62 | 62 | ||
63 | logger.info('Testing SMTP server...') | ||
64 | |||
63 | try { | 65 | try { |
64 | const success = await this.transporter.verify() | 66 | const success = await this.transporter.verify() |
65 | if (success !== true) this.dieOnConnectionFailure() | 67 | if (success !== true) this.dieOnConnectionFailure() |