]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.ts
Translated using Weblate (Czech)
[github/Chocobozzz/PeerTube.git] / server.ts
index 6a7dad0cdf00b6e0ddbd191890ea5c9d2a056b2c..3859964702cedb542e023a380b025f45023117cc 100644 (file)
--- a/server.ts
+++ b/server.ts
@@ -1,11 +1,3 @@
-import { registerTSPaths } from './server/helpers/register-ts-paths'
-registerTSPaths()
-
-import { isTestInstance } from './server/helpers/core-utils'
-if (isTestInstance()) {
-  require('source-map-support').install()
-}
-
 // ----------- Node modules -----------
 import express from 'express'
 import morgan, { token } from 'morgan'
@@ -19,7 +11,7 @@ import { program as cli } from 'commander'
 process.title = 'peertube'
 
 // Create our main app
-const app = express().disable("x-powered-by")
+const app = express().disable('x-powered-by')
 
 // ----------- Core checker -----------
 import { checkMissedConfig, checkFFmpeg, checkNodeVersion } from './server/initializers/checker-before-init'
@@ -41,7 +33,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'
 
@@ -130,12 +127,14 @@ 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'
+import { isTestInstance } from './server/helpers/core-utils'
 
 // ----------- 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 -----------
@@ -324,6 +323,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', () => {