]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server.ts
Add/update OpenRC service script (#2012)
[github/Chocobozzz/PeerTube.git] / server.ts
index f6fae3718f36ba30da213ed2f65f15588b569416..50511a90684c7ec3599c8818f8ded3509ebd5eb7 100644 (file)
--- a/server.ts
+++ b/server.ts
@@ -26,7 +26,7 @@ process.title = 'peertube'
 const app = express()
 
 // ----------- Core checker -----------
-import { checkMissedConfig, checkFFmpeg } from './server/initializers/checker-before-init'
+import { checkMissedConfig, checkFFmpeg, checkNodeVersion } from './server/initializers/checker-before-init'
 
 // Do not use barrels because we don't want to load all modules here (we need to initialize database first)
 import { CONFIG } from './server/initializers/config'
@@ -45,6 +45,8 @@ checkFFmpeg(CONFIG)
     process.exit(-1)
   })
 
+checkNodeVersion()
+
 import { checkConfig, checkActivityPubUrls } from './server/initializers/checker-after-init'
 
 const errorMessage = checkConfig()
@@ -95,6 +97,7 @@ import {
   clientsRouter,
   feedsRouter,
   staticRouter,
+  lazyStaticRouter,
   servicesRouter,
   pluginsRouter,
   webfingerRouter,
@@ -113,11 +116,14 @@ import { RemoveOldHistoryScheduler } from './server/lib/schedulers/remove-old-hi
 import { isHTTPSignatureDigestValid } from './server/helpers/peertube-crypto'
 import { PeerTubeSocket } from './server/lib/peertube-socket'
 import { updateStreamingPlaylistsInfohashesIfNeeded } from './server/lib/hls'
+import { PluginsCheckScheduler } from './server/lib/schedulers/plugins-check-scheduler'
+import { Hooks } from './server/lib/plugins/hooks'
 
 // ----------- Command line -----------
 
 cli
   .option('--no-client', 'Start PeerTube without client interface')
+  .option('--no-plugins', 'Start PeerTube without plugins/themes enabled')
   .parse(process.argv)
 
 // ----------- App -----------
@@ -187,6 +193,7 @@ app.use('/', botsRouter)
 
 // Static files
 app.use('/', staticRouter)
+app.use('/', lazyStaticRouter)
 
 // Client files, last valid routes!
 if (cli.client) app.use('/', clientsRouter)
@@ -250,6 +257,7 @@ async function startApplication () {
   VideosRedundancyScheduler.Instance.enable()
   RemoveOldHistoryScheduler.Instance.enable()
   RemoveOldViewsScheduler.Instance.enable()
+  PluginsCheckScheduler.Instance.enable()
 
   // Redis initialization
   Redis.Instance.init()
@@ -259,14 +267,14 @@ async function startApplication () {
   updateStreamingPlaylistsInfohashesIfNeeded()
     .catch(err => logger.error('Cannot update streaming playlist infohashes.', { err }))
 
-  await PluginManager.Instance.registerPluginsAndThemes()
+  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)
 
-    PluginManager.Instance.runHook('action:application.listening')
+    Hooks.runAction('action:application.listening')
   })
 
   process.on('exit', () => {