X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server.ts;h=dc7a71d608c2555e9edb648581234c7b8804ced7;hb=053ad3a346a817a3d11106a13079d675a182dca8;hp=99077a1738c498c2f7076ccf87c23aaa94272b26;hpb=60650c77c8a2a98e92d869b237ae4900f369a8fc;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server.ts b/server.ts index 99077a173..dc7a71d60 100644 --- a/server.ts +++ b/server.ts @@ -53,10 +53,13 @@ migrate() // ----------- PeerTube modules ----------- import { installApplication } from './server/initializers' -import { activitypubHttpJobScheduler, transcodingJobScheduler } from './server/lib/jobs' +import { Emailer } from './server/lib/emailer' +import { JobQueue } from './server/lib/job-queue' import { VideosPreviewCache } from './server/lib/cache' import { apiRouter, clientsRouter, staticRouter, servicesRouter, webfingerRouter, activityPubRouter } from './server/controllers' +import { Redis } from './server/lib/redis' import { BadActorFollowScheduler } from './server/lib/schedulers/bad-actor-follow-scheduler' +import { RemoveOldJobsScheduler } from './server/lib/schedulers/remove-old-jobs-scheduler' // ----------- Command line ----------- @@ -82,7 +85,7 @@ if (isTestInstance()) { // For the logger app.use(morgan('combined', { - stream: { write: logger.info } + stream: { write: logger.info.bind(logger) } })) // For body requests app.use(bodyParser.json({ @@ -101,11 +104,11 @@ const trackerServer = new TrackerServer({ }) trackerServer.on('error', function (err) { - logger.error(err) + logger.error('Error in websocket tracker.', err) }) trackerServer.on('warning', function (err) { - logger.error(err) + logger.error('Warning in websocket tracker.', err) }) const server = http.createServer(app) @@ -168,11 +171,20 @@ function onDatabaseInitDone () { .then(() => { // ----------- Make the server listening ----------- server.listen(port, () => { + // Emailer initialization and then job queue initialization + Emailer.Instance.init() + Emailer.Instance.checkConnectionOrDie() + .then(() => JobQueue.Instance.init()) + + // Caches initializations VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE) + + // Enable Schedulers BadActorFollowScheduler.Instance.enable() + RemoveOldJobsScheduler.Instance.enable() - activitypubHttpJobScheduler.activate() - transcodingJobScheduler.activate() + // Redis initialization + Redis.Instance.init() logger.info('Server listening on port %d', port) logger.info('Web server: %s', CONFIG.WEBSERVER.URL)