+ // Caches initializations
+ VideosPreviewCache.Instance.init(CONFIG.CACHE.PREVIEWS.SIZE, FILES_CACHE.PREVIEWS.MAX_AGE)
+ VideosCaptionCache.Instance.init(CONFIG.CACHE.VIDEO_CAPTIONS.SIZE, FILES_CACHE.VIDEO_CAPTIONS.MAX_AGE)
+
+ // Enable Schedulers
+ ActorFollowScheduler.Instance.enable()
+ RemoveOldJobsScheduler.Instance.enable()
+ UpdateVideosScheduler.Instance.enable()
+ YoutubeDlUpdateScheduler.Instance.enable()
+ VideosRedundancyScheduler.Instance.enable()
+ RemoveOldHistoryScheduler.Instance.enable()
+ RemoveOldViewsScheduler.Instance.enable()
+ PluginsCheckScheduler.Instance.enable()
+
+ // Redis initialization
+ Redis.Instance.init()
+
+ PeerTubeSocket.Instance.init(server)
+
+ updateStreamingPlaylistsInfohashesIfNeeded()
+ .catch(err => logger.error('Cannot update streaming playlist infohashes.', { err }))
+
+ if (cli.plugins) await PluginManager.Instance.registerPluginsAndThemes()
+
+ // Make server listening
+ server.listen(port, hostname, () => {
+ logger.info('Server listening on %s:%d', hostname, port)
+ logger.info('Web server: %s', WEBSERVER.URL)
+
+ Hooks.runAction('action:application.listening')
+ })
+
+ process.on('exit', () => {
+ JobQueue.Instance.terminate()
+ })
+
+ process.on('SIGINT', () => process.exit(0))