aboutsummaryrefslogtreecommitdiffhomepage
path: root/scripts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2022-08-09 09:09:31 +0200
committerChocobozzz <me@florianbigard.com>2022-08-09 09:32:17 +0200
commitb42c2c7e89a64ed730d8140840fe74a13c31f2a4 (patch)
tree715e7ad31d03881e3f3530dba1fe3d172251249b /scripts
parentbd911b54b555b11df7e9849cf92d358bccfecf6e (diff)
downloadPeerTube-b42c2c7e89a64ed730d8140840fe74a13c31f2a4.tar.gz
PeerTube-b42c2c7e89a64ed730d8140840fe74a13c31f2a4.tar.zst
PeerTube-b42c2c7e89a64ed730d8140840fe74a13c31f2a4.zip
Avoid concurrency issue on transcoding
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/create-transcoding-job.ts11
1 files changed, 6 insertions, 5 deletions
diff --git a/scripts/create-transcoding-job.ts b/scripts/create-transcoding-job.ts
index f8c0ed461..aa97b0ba7 100755
--- a/scripts/create-transcoding-job.ts
+++ b/scripts/create-transcoding-job.ts
@@ -2,7 +2,7 @@ import { program } from 'commander'
2import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' 2import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc'
3import { computeResolutionsToTranscode } from '@server/helpers/ffmpeg' 3import { computeResolutionsToTranscode } from '@server/helpers/ffmpeg'
4import { CONFIG } from '@server/initializers/config' 4import { CONFIG } from '@server/initializers/config'
5import { addTranscodingJob } from '@server/lib/video' 5import { buildTranscodingJob } from '@server/lib/video'
6import { VideoState, VideoTranscodingPayload } from '@shared/models' 6import { VideoState, VideoTranscodingPayload } from '@shared/models'
7import { initDatabaseModels } from '../server/initializers/database' 7import { initDatabaseModels } from '../server/initializers/database'
8import { JobQueue } from '../server/lib/job-queue' 8import { JobQueue } from '../server/lib/job-queue'
@@ -57,7 +57,7 @@ async function run () {
57 57
58 for (const resolution of resolutionsEnabled) { 58 for (const resolution of resolutionsEnabled) {
59 dataInput.push({ 59 dataInput.push({
60 type: 'new-resolution-to-hls', 60 type: 'new-resolution-to-hls' as 'new-resolution-to-hls',
61 videoUUID: video.uuid, 61 videoUUID: video.uuid,
62 resolution, 62 resolution,
63 63
@@ -72,7 +72,7 @@ async function run () {
72 } else { 72 } else {
73 if (options.resolution !== undefined) { 73 if (options.resolution !== undefined) {
74 dataInput.push({ 74 dataInput.push({
75 type: 'new-resolution-to-webtorrent', 75 type: 'new-resolution-to-webtorrent' as 'new-resolution-to-webtorrent',
76 videoUUID: video.uuid, 76 videoUUID: video.uuid,
77 77
78 createHLSIfNeeded: true, 78 createHLSIfNeeded: true,
@@ -90,7 +90,7 @@ async function run () {
90 } 90 }
91 91
92 dataInput.push({ 92 dataInput.push({
93 type: 'optimize-to-webtorrent', 93 type: 'optimize-to-webtorrent' as 'optimize-to-webtorrent',
94 videoUUID: video.uuid, 94 videoUUID: video.uuid,
95 isNewVideo: false 95 isNewVideo: false
96 }) 96 })
@@ -103,7 +103,8 @@ async function run () {
103 await video.save() 103 await video.save()
104 104
105 for (const d of dataInput) { 105 for (const d of dataInput) {
106 await addTranscodingJob(d, {}) 106 await JobQueue.Instance.createJob(await buildTranscodingJob(d))
107
107 console.log('Transcoding job for video %s created.', video.uuid) 108 console.log('Transcoding job for video %s created.', video.uuid)
108 } 109 }
109} 110}