diff options
author | Chocobozzz <me@florianbigard.com> | 2022-08-09 09:09:31 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-08-09 09:32:17 +0200 |
commit | b42c2c7e89a64ed730d8140840fe74a13c31f2a4 (patch) | |
tree | 715e7ad31d03881e3f3530dba1fe3d172251249b /scripts/create-transcoding-job.ts | |
parent | bd911b54b555b11df7e9849cf92d358bccfecf6e (diff) | |
download | PeerTube-b42c2c7e89a64ed730d8140840fe74a13c31f2a4.tar.gz PeerTube-b42c2c7e89a64ed730d8140840fe74a13c31f2a4.tar.zst PeerTube-b42c2c7e89a64ed730d8140840fe74a13c31f2a4.zip |
Avoid concurrency issue on transcoding
Diffstat (limited to 'scripts/create-transcoding-job.ts')
-rwxr-xr-x | scripts/create-transcoding-job.ts | 11 |
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' | |||
2 | import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' | 2 | import { isUUIDValid, toCompleteUUID } from '@server/helpers/custom-validators/misc' |
3 | import { computeResolutionsToTranscode } from '@server/helpers/ffmpeg' | 3 | import { computeResolutionsToTranscode } from '@server/helpers/ffmpeg' |
4 | import { CONFIG } from '@server/initializers/config' | 4 | import { CONFIG } from '@server/initializers/config' |
5 | import { addTranscodingJob } from '@server/lib/video' | 5 | import { buildTranscodingJob } from '@server/lib/video' |
6 | import { VideoState, VideoTranscodingPayload } from '@shared/models' | 6 | import { VideoState, VideoTranscodingPayload } from '@shared/models' |
7 | import { initDatabaseModels } from '../server/initializers/database' | 7 | import { initDatabaseModels } from '../server/initializers/database' |
8 | import { JobQueue } from '../server/lib/job-queue' | 8 | import { 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 | } |