]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.ts
Refactor plugin card
[github/Chocobozzz/PeerTube.git] / server.ts
index b8c1d12517e21666a1b00d314d6e20dbf34cade2..f4f448e6b4732304b7c0f642067d3e8198f10171 100644 (file)
--- a/server.ts
+++ b/server.ts
@@ -41,7 +41,12 @@ checkFFmpeg(CONFIG)
     process.exit(-1)
   })
 
-checkNodeVersion()
+try {
+  checkNodeVersion()
+} catch (err) {
+  logger.error('Error in NodeJS check.', { err })
+  process.exit(-1)
+}
 
 import { checkConfig, checkActivityPubUrls, checkFFmpegVersion } from './server/initializers/checker-after-init'
 
@@ -117,6 +122,7 @@ import { VideosRedundancyScheduler } from './server/lib/schedulers/videos-redund
 import { RemoveOldHistoryScheduler } from './server/lib/schedulers/remove-old-history-scheduler'
 import { AutoFollowIndexInstances } from './server/lib/schedulers/auto-follow-index-instances'
 import { RemoveDanglingResumableUploadsScheduler } from './server/lib/schedulers/remove-dangling-resumable-uploads-scheduler'
+import { VideoViewsBufferScheduler } from './server/lib/schedulers/video-views-buffer-scheduler'
 import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto'
 import { PeerTubeSocket } from './server/lib/peertube-socket'
 import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls'
@@ -128,12 +134,14 @@ import { LiveManager } from './server/lib/live'
 import { HttpStatusCode } from './shared/models/http/http-error-codes'
 import { VideosTorrentCache } from '@server/lib/files-cache/videos-torrent-cache'
 import { ServerConfigManager } from '@server/lib/server-config-manager'
+import { VideoViews } from '@server/lib/video-views'
 
 // ----------- Command line -----------
 
 cli
   .option('--no-client', 'Start PeerTube without client interface')
   .option('--no-plugins', 'Start PeerTube without plugins/themes enabled')
+  .option('--benchmark-startup', 'Automatically stop server when initialized')
   .parse(process.argv)
 
 // ----------- App -----------
@@ -296,11 +304,11 @@ async function startApplication () {
   PeerTubeVersionCheckScheduler.Instance.enable()
   AutoFollowIndexInstances.Instance.enable()
   RemoveDanglingResumableUploadsScheduler.Instance.enable()
+  VideoViewsBufferScheduler.Instance.enable()
 
-  // Redis initialization
   Redis.Instance.init()
-
   PeerTubeSocket.Instance.init(server)
+  VideoViews.Instance.init()
 
   updateStreamingPlaylistsInfohashesIfNeeded()
     .catch(err => logger.error('Cannot update streaming playlist infohashes.', { err }))
@@ -322,6 +330,8 @@ async function startApplication () {
     logger.info('Web server: %s', WEBSERVER.URL)
 
     Hooks.runAction('action:application.listening')
+
+    if (cliOptions['benchmarkStartup']) process.exit(0)
   })
 
   process.on('exit', () => {