1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Avoid concurrency issue on transcoding

This commit is contained in:
Chocobozzz 2022-08-09 09:09:31 +02:00
parent bd911b54b5
commit b42c2c7e89
No known key found for this signature in database
GPG key ID: 583A612D890159BE
8 changed files with 120 additions and 54 deletions

View file

@ -325,10 +325,8 @@ class JobQueue {
if (!job) continue
lastJob = {
name: 'job',
data: job.payload,
queueName: job.type,
opts: this.buildJobOptions(job.type as JobType, pick(job, [ 'priority', 'delay' ])),
...this.buildJobFlowOption(job),
children: lastJob
? [ lastJob ]
: []
@ -338,6 +336,23 @@ class JobQueue {
return this.flowProducer.add(lastJob)
}
async createJobWithChildren (parent: CreateJobArgument & CreateJobOptions, children: (CreateJobArgument & CreateJobOptions)[]) {
return this.flowProducer.add({
...this.buildJobFlowOption(parent),
children: children.map(c => this.buildJobFlowOption(c))
})
}
private buildJobFlowOption (job: CreateJobArgument & CreateJobOptions) {
return {
name: 'job',
data: job.payload,
queueName: job.type,
opts: this.buildJobOptions(job.type as JobType, pick(job, [ 'priority', 'delay' ]))
}
}
private buildJobOptions (type: JobType, options: CreateJobOptions = {}): JobsOptions {
return {
backoff: { delay: 60 * 1000, type: 'exponential' },
@ -425,10 +440,6 @@ class JobQueue {
}
}
waitJob (job: Job) {
return job.waitUntilFinished(this.queueEvents[job.queueName])
}
private addRepeatableJobs () {
this.queues['videos-views-stats'].add('job', {}, {
repeat: REPEAT_JOBS['videos-views-stats']