diff options
author | Chocobozzz <florian.bigard@gmail.com> | 2016-07-21 17:15:29 +0200 |
---|---|---|
committer | Chocobozzz <florian.bigard@gmail.com> | 2016-07-21 17:15:29 +0200 |
commit | 419633ce9df63d7964872e833faa8b603d4e0ebf (patch) | |
tree | 98039d8da2ab83b6306c11339652556624ee8d9f /server | |
parent | 798442f6655c5f699341e158cb6ec87c40db2c6b (diff) | |
download | PeerTube-419633ce9df63d7964872e833faa8b603d4e0ebf.tar.gz PeerTube-419633ce9df63d7964872e833faa8b603d4e0ebf.tar.zst PeerTube-419633ce9df63d7964872e833faa8b603d4e0ebf.zip |
Server: throttle "seedAll" when starting the server
Diffstat (limited to 'server')
-rw-r--r-- | server/initializers/constants.js | 5 | ||||
-rw-r--r-- | server/models/video.js | 4 |
2 files changed, 7 insertions, 2 deletions
diff --git a/server/initializers/constants.js b/server/initializers/constants.js index 7fcf5b01b..467816f2c 100644 --- a/server/initializers/constants.js +++ b/server/initializers/constants.js | |||
@@ -40,6 +40,10 @@ const SEARCHABLE_COLUMNS = { | |||
40 | VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ] | 40 | VIDEOS: [ 'name', 'magnetUri', 'podUrl', 'author', 'tags' ] |
41 | } | 41 | } |
42 | 42 | ||
43 | // Seeds in parallel we send to electron when "seed all" | ||
44 | // Once a video is in seeding state we seed another video etc | ||
45 | const SEEDS_IN_PARALLEL = 3 | ||
46 | |||
43 | // Sortable columns per schema | 47 | // Sortable columns per schema |
44 | const SORTABLE_COLUMNS = { | 48 | const SORTABLE_COLUMNS = { |
45 | VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ] | 49 | VIDEOS: [ 'name', '-name', 'duration', '-duration', 'createdDate', '-createdDate' ] |
@@ -83,6 +87,7 @@ module.exports = { | |||
83 | REQUESTS_LIMIT: REQUESTS_LIMIT, | 87 | REQUESTS_LIMIT: REQUESTS_LIMIT, |
84 | RETRY_REQUESTS: RETRY_REQUESTS, | 88 | RETRY_REQUESTS: RETRY_REQUESTS, |
85 | SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS, | 89 | SEARCHABLE_COLUMNS: SEARCHABLE_COLUMNS, |
90 | SEEDS_IN_PARALLEL: SEEDS_IN_PARALLEL, | ||
86 | SORTABLE_COLUMNS: SORTABLE_COLUMNS, | 91 | SORTABLE_COLUMNS: SORTABLE_COLUMNS, |
87 | THUMBNAILS_SIZE: THUMBNAILS_SIZE, | 92 | THUMBNAILS_SIZE: THUMBNAILS_SIZE, |
88 | THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH, | 93 | THUMBNAILS_STATIC_PATH: THUMBNAILS_STATIC_PATH, |
diff --git a/server/models/video.js b/server/models/video.js index 98f43a06d..396aa505d 100644 --- a/server/models/video.js +++ b/server/models/video.js | |||
@@ -1,7 +1,7 @@ | |||
1 | 'use strict' | 1 | 'use strict' |
2 | 2 | ||
3 | const config = require('config') | 3 | const config = require('config') |
4 | const each = require('async/each') | 4 | const eachLimit = require('async/eachLimit') |
5 | const ffmpeg = require('fluent-ffmpeg') | 5 | const ffmpeg = require('fluent-ffmpeg') |
6 | const fs = require('fs') | 6 | const fs = require('fs') |
7 | const parallel = require('async/parallel') | 7 | const parallel = require('async/parallel') |
@@ -235,7 +235,7 @@ function seedAllExisting (callback) { | |||
235 | listOwned.call(this, function (err, videos) { | 235 | listOwned.call(this, function (err, videos) { |
236 | if (err) return callback(err) | 236 | if (err) return callback(err) |
237 | 237 | ||
238 | each(videos, function (video, callbackEach) { | 238 | eachLimit(videos, constants.SEEDS_IN_PARALLEL, function (video, callbackEach) { |
239 | const videoPath = pathUtils.join(uploadsDir, video.filename) | 239 | const videoPath = pathUtils.join(uploadsDir, video.filename) |
240 | seed(videoPath, callbackEach) | 240 | seed(videoPath, callbackEach) |
241 | }, callback) | 241 | }, callback) |