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:
parent
bd911b54b5
commit
b42c2c7e89
8 changed files with 120 additions and 54 deletions
|
@ -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']
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue