]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
Server: throttle "seedAll" when starting the server
authorChocobozzz <florian.bigard@gmail.com>
Thu, 21 Jul 2016 15:15:29 +0000 (17:15 +0200)
committerChocobozzz <florian.bigard@gmail.com>
Thu, 21 Jul 2016 15:15:29 +0000 (17:15 +0200)
server/initializers/constants.js
server/models/video.js

index 7fcf5b01bb2fb219f489e8d3379be35acd740eb0..467816f2cd539501d70a372df5cb9c829e471633 100644 (file)
@@ -40,6 +40,10 @@ const SEARCHABLE_COLUMNS = {
   VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ]
 }
 
+// Seeds in parallel we send to electron when "seed all"
+// Once a video is in seeding state we seed another video etc
+const SEEDS_IN_PARALLEL = 3
+
 // Sortable columns per schema
 const SORTABLE_COLUMNS = {
   VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ]
@@ -83,6 +87,7 @@ module.exports = {
   REQUESTS_LIMIT: REQUESTS_LIMIT,
   RETRY_REQUESTS: RETRY_REQUESTS,
   SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS,
+  SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL,
   SORTABLE_COLUMNS: SORTABLE_COLUMNS,
   THUMBNAILS_SIZE: THUMBNAILS_SIZE,
   THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH,
index 98f43a06de86ed03baec25b49019a61fe0b474a5..396aa505d5e1e1efd1e02b43646eb06ab15694ac 100644 (file)
@@ -1,7 +1,7 @@
 'use strict'
 
 const config = require('config')
-const each = require('async/each')
+const eachLimit = require('async/eachLimit')
 const ffmpeg = require('fluent-ffmpeg')
 const fs = require('fs')
 const parallel = require('async/parallel')
@@ -235,7 +235,7 @@ function seedAllExisting (callback) {
   listOwned.call(this, function (err, videos) {
     if (err) return callback(err)
 
-    each(videos, function (video, callbackEach) {
+    eachLimit(videos, constants.SEEDS_IN_PARALLEL, function (video, callbackEach) {
       const videoPath = pathUtils.join(uploadsDir, video.filename)
       seed(videoPath, callbackEach)
     }, callback)