+
+ checkFFmpegVersion()
+ .catch(err => logger.error('Cannot check ffmpeg version', { err }))
+
+ Redis.Instance.init()
+ Emailer.Instance.init()
+
+ await Promise.all([
+ Emailer.Instance.checkConnection(),
+ JobQueue.Instance.init(),
+ ServerConfigManager.Instance.init()
+ ])
+
+ // 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)
+ VideosTorrentCache.Instance.init(CONFIG.CACHE.TORRENTS.SIZE, FILES_CACHE.TORRENTS.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()
+ PeerTubeVersionCheckScheduler.Instance.enable()
+ AutoFollowIndexInstances.Instance.enable()
+ RemoveDanglingResumableUploadsScheduler.Instance.enable()
+ VideoViewsBufferScheduler.Instance.enable()
+ GeoIPUpdateScheduler.Instance.enable()
+ OpenTelemetryMetrics.Instance.registerMetrics()
+
+ PeerTubeSocket.Instance.init(server)
+ VideoViewsManager.Instance.init()
+
+ updateStreamingPlaylistsInfohashesIfNeeded()
+ .catch(err => logger.error('Cannot update streaming playlist infohashes.', { err }))
+
+ LiveManager.Instance.init()
+ if (CONFIG.LIVE.ENABLED) await LiveManager.Instance.run()
+
+ // Make server listening
+ server.listen(port, hostname, async () => {
+ if (cliOptions.plugins) {
+ try {
+ await PluginManager.Instance.registerPluginsAndThemes()
+ } catch (err) {
+ logger.error('Cannot register plugins and themes.', { err })
+ }
+ }
+
+ logger.info('HTTP server listening on %s:%d', hostname, port)
+ logger.info('Web server: %s', WEBSERVER.URL)
+
+ Hooks.runAction('action:application.listening')
+
+ if (cliOptions['benchmarkStartup']) process.exit(0)
+ })
+
+ process.on('exit', () => {
+ JobQueue.Instance.terminate()
+ })
+
+ process.on('SIGINT', () => process.exit(0))